#10963: More functorial constructions
-------------------------------------+-------------------------------------
       Reporter:  nthiery            |        Owner:  stumpc5
           Type:  enhancement        |       Status:  needs_review
       Priority:  major              |    Milestone:  sage-6.1
      Component:  categories         |   Resolution:
       Keywords:  days54             |    Merged in:
        Authors:  Nicolas M. Thiéry  |    Reviewers:  Simon King, Frédéric
Report Upstream:  N/A                |  Chapoton
         Branch:                     |  Work issues:
  public/ticket/10963                |       Commit:
   Dependencies:  #11224, #8327,     |  dbb17b11bb9e8f94b5d9d3424cd34c5efc82564c
  #10193, #12895, #14516, #14722,    |     Stopgaps:
  #13589, #14471, #15069, #15094,    |
  #11688, #13394, #15150, #15506     |
-------------------------------------+-------------------------------------

Comment (by nbruin):

 I have to think about your explanation. I have a hunch there's a problem
 with it but as long as I cannot point it out explicitly I cannot really
 object.

 Independently, the lazy import indeed doesn't seem to clear properly, as
 was indicated by the tracebacks above already. With
 {{{#!diff
 diff --git a/src/sage/misc/lazy_import.pyx b/src/sage/misc/lazy_import.pyx
 index 051a99b..2b96582 100644
 --- a/src/sage/misc/lazy_import.pyx
 +++ b/src/sage/misc/lazy_import.pyx
 @@ -480,6 +480,7 @@ cdef class LazyImport(object):
          documentation of :meth:`_get_object` for an explanation of
          this.
          """
 +        print "lazy_import.__get__(%s,%s,%s)"%(self, instance, owner)
          obj = self._get_object(owner=owner)
          if hasattr(obj, "__get__"):
              return obj.__get__(instance, owner)
 }}}
 I get:
 {{{
 sage: Algebras(GF(13))
 lazy_import.__get__(<class
 'sage.categories.associative_algebras.AssociativeAlgebras'>,None,<class
 'sage.categories.magmatic_algebras.MagmaticAlgebras_with_category'>)
 lazy_import.__get__(<class
 'sage.categories.algebras.Algebras'>,None,<class
 'sage.categories.associative_algebras.AssociativeAlgebras_with_category'>)
 lazy_import.__get__(<class
 'sage.categories.unital_algebras.UnitalAlgebras'>,None,<class
 'sage.categories.magmatic_algebras.MagmaticAlgebras_with_category'>)
 Category of algebras over Finite Field of size 13
 sage: Algebras(GF(5))
 lazy_import.__get__(<class
 'sage.categories.associative_algebras.AssociativeAlgebras'>,None,<class
 'sage.categories.magmatic_algebras.MagmaticAlgebras_with_category'>)
 lazy_import.__get__(<class
 'sage.categories.algebras.Algebras'>,None,<class
 'sage.categories.associative_algebras.AssociativeAlgebras_with_category'>)
 lazy_import.__get__(<class
 'sage.categories.unital_algebras.UnitalAlgebras'>,None,<class
 'sage.categories.magmatic_algebras.MagmaticAlgebras_with_category'>)
 Category of algebras over Finite Field of size 5
 sage: Algebras(GF(7))
 lazy_import.__get__(<class
 'sage.categories.associative_algebras.AssociativeAlgebras'>,None,<class
 'sage.categories.magmatic_algebras.MagmaticAlgebras_with_category'>)
 lazy_import.__get__(<class
 'sage.categories.algebras.Algebras'>,None,<class
 'sage.categories.associative_algebras.AssociativeAlgebras_with_category'>)
 lazy_import.__get__(<class
 'sage.categories.unital_algebras.UnitalAlgebras'>,None,<class
 'sage.categories.magmatic_algebras.MagmaticAlgebras_with_category'>)
 Category of algebras over Finite Field of size 7
 }}}
 After the first call, all the lazy importing should have happened already,
 so subsequent invocations shouldn't have a lazy_import in between any
 more. I suspect that this happens because there is a lazy import object
 somewhere that doesn't get replaced by the reference to the actual object
 once it gets loaded. This is a known issue: lazy_importing objects from
 modules doesn't actually work very well (lazy importing modules and then
 referring to an object in the module works better, if I'm not mistaken).

 So, you should probably not use lazy import for this but rather do it
 manually: just keep the string first and do an actual import, replacing
 the string, once you really need the object.

--
Ticket URL: <http://trac.sagemath.org/ticket/10963#comment:340>
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/groups/opt_out.

Reply via email to