#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):

 OK, and these are the counts for lazy_import objects bound in scopes that
 is not theirs:
 {{{
 from sage.misc.lazy_import import LazyImport,att #that's the helper
 function
 def misbound_lazies(S):
   return [k for k,v in S.iteritems() if type(v) is LazyImport and
 att(v)['_namespace'] is not S]
 M=[(k,len(misbound_lazies(m.__dict__))) for k,m in sys.modules.iteritems()
 if m is not None]
 }}}
 {{{
 sage: [m for m in M if m[1] > 0]
 [('sage.combinat.tableau_tuple', 1),
  ('sage.libs.linbox.linbox', 1),
  ('sage.groups.libgap_mixin', 1),
  ('__main__', 190),
  ('sage.categories.all', 1),
  ('sage.combinat.all', 34),
  ('sage.calculus.all', 1),
  ('sage.geometry.all', 3),
  ('sage.functions.piecewise', 1),
  ('sage.structure.sage_object', 1),
  ('sage.combinat.partition_tuple', 1),
  ('sage.modular.arithgroup.congroup_generic', 1),
  ('sage.schemes.all', 6),
  ('sage.rings.all', 3),
  ('sage.functions.special', 1),
  ('sage.functions.airy', 1),
  ('sage.all_cmdline', 190),
  ('sage.libs.pari.gen_py', 4),
  ('sage.structure.coerce', 1),
  ('sage.functions.bessel', 1),
  ('sage.functions.orthogonal_polys', 1),
  ('sage.numerical.interactive_simplex_method', 1),
  ('sage.combinat.integer_vectors_mod_permgroup', 1),
  ('sage.groups.all', 10),
  ('sage.combinat.crystals.tensor_product', 1),
  ('sage.combinat.composition', 1),
  ('sage.categories.groups', 1),
  ('sage.combinat.partition', 1),
  ('sage.all', 165)]
 sage: len(set(flatten([misbound_lazies(m.__dict__) for m in
 sys.modules.values() if m is not None])))
 195
 }}}
 So, assuming that symbol name is a good indication, there seem to be about
 195 distinct lazy_import objects around that are bound in wrong scopes.

 Most frequently occurring:
 {{{
 sage: L=[misbound_lazies(m.__dict__) for m in sys.modules.values() if m is
 not None]
 sage: sorted(Counter(flatten(L)).items(),key=lambda a:a[1])[-20:]
 [('WehlerK3Surface', 4),
  ('ClusterQuiver', 4),
  ('CrystalOfNakajimaMonomials', 4),
  ('KostkaFoulkesPolynomial', 4),
  ('polytopes', 4),
  ('ExtendedAffineWeylGroup', 4),
  ('QuaternionMatrixGroupGF3', 4),
  ('KirillovReshetikhinTableaux', 4),
  ('CrystalOfGeneralizedYoungWalls', 4),
  ('maxima_calculus', 4),
  ('AffineCrystalFromClassical', 4),
  ('ClusterSeed', 4),
  ('QuiverMutationType', 4),
  ('maxima', 4),
  ('NonNegativeIntegerSemiring', 5),
  ('Polyhedron', 5),
  ('MatrixGroup', 5),
  ('AsymptoticRing', 5),
  ('cartesian_product', 7),
  ('NN', 9)]
 }}}

--
Ticket URL: <http://trac.sagemath.org/ticket/19628#comment:22>
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