On Mar 1, 3:43 pm, "Johan S. R. Nielsen" <j.s.r.niel...@mat.dtu.dk> wrote: > On Mar 1, 1:56 pm, luisfe <lftab...@yahoo.es> wrote: > > > > > > > No, the lazy_import object keeps wrapping the original object, but > > when accessing the lazy_import object it imports the real object in > > the namespace. So, if the lazy_import has not been referenced by > > another object then it will be collected as garbage. I do not have a > > running sage right now, but if you experiment you will see that after > > calling the object the lazy_import object disappears. > > > It should be something like: > > > {{{ > > sage: from sage.misc.lazy_import import lazy_import > > sage: lazy_import('sage.rings.all', 'ZZ') > > sage: a = ZZ > > sage: type(ZZ) > > <class 'sage.misc.lazy_import.LazyImport'> > > sage: ZZ(4.0) > > 4 > > sage: type(ZZ) > > <type 'sage.rings.integer_ring.IntegerRing_class'> > > sage: type(a) > > <class 'sage.misc.lazy_import.LazyImport'> > > > }}} > > I just did the above in 4.6.1 and got: > {{{ > sage: lazy_import('sage.rings.all','ZZ') > sage: a = ZZ > sage: type(ZZ) > <class 'sage.misc.lazy_import.LazyImport'> > sage: ZZ(4.0) > 4 > sage: type(ZZ) > <class 'sage.misc.lazy_import.LazyImport'>}}} > > And naturally, the same type for a. It seems nothing I do to the ZZ > object will unwrap it from the LazyImporter; otherwise, what you say > would naturally be true, and that was exactly what I thought would be > neat to do. Even though the wrapping is very thin, if each and every > callable was wrapped as such, it would probably be quite a large > performance-penalty. > > Johan
Oops, my mistake, I am using a developper version. Try with sage-4.6.2 (to be released this week) the improvement I am talking about was merged in 4.6.2.alpha3 Also lazy_import('sage.rings.all','ZZ') does not need disk access, is lazy_import('sage.rings'all','*') what needs to read the file. -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org