#19628: lazy_import breaks CachedRepresentation
----------------------------+-------------------------
       Reporter:  cheuberg  |        Owner:
           Type:  defect    |       Status:  new
       Priority:  major     |    Milestone:  sage-6.10
      Component:  coercion  |   Resolution:
       Keywords:            |    Merged in:
        Authors:            |    Reviewers:
Report Upstream:  N/A       |  Work issues:
         Branch:            |       Commit:
   Dependencies:            |     Stopgaps:
----------------------------+-------------------------

Comment (by nbruin):

 Replying to [comment:26 jdemeyer]:
 > Replying to [comment:24 nbruin]:
 > > You can of course try to extend the use of lazy_import and see if you
 can get it to work for things like NN as well.
 >
 > I would certainly like to try that. It would be a pity if rings (like
 `NN`) are fundamentally incompatible with `lazy_import`. Consider `arb`
 for example: it makes sense to define a global `RBF` (for real ball
 field), analogous to `RR`. It also makes a lot of sense to lazily import
 this: it's unlikely to be commonly used, it would save an import of at
 least 2 Python modules and it would save the loading of the external
 library `libarb`.

 We can do that at the cost of a namespace:
 {{{
 realballfield.RBF
 natural_numbers.NN
 }}}
 (where `realballfield` and `natural_numbers` can be lazily imported) or at
 the cost of an accessor function (lazily imported):
 {{{
 RealBallField()
 NaturalNumbers()
 }}}
 The fact that
 {{{
 D=dict()
 D[NN]=1
 D[NN]=2
 }}}
 will never work properly makes trying to pretend otherwise a non-starter
 in my opinion. You'd have to reach too deeply into python (you probably
 wouldn't even be able to distinguish between the "initialization" code
 where the Lazy object needs to be passed and genuine access, where you do
 need to dereference).

 We could reach into various sage infrastructures and special-case
 LazyImports there, but in my opinion that would just increase the surprise
 factor when other constructs fail.

--
Ticket URL: <http://trac.sagemath.org/ticket/19628#comment:27>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to