#15367: Empty lists while creating parents
-----------------------+-----------------------------
   Reporter:  roed     |            Owner:
       Type:  defect   |           Status:  new
   Priority:  major    |        Milestone:  sage-5.13
  Component:  memleak  |         Keywords:
  Merged in:           |          Authors:
  Reviewers:           |  Report Upstream:  N/A
Work issues:           |           Branch:
     Commit:           |     Dependencies:
   Stopgaps:           |
-----------------------+-----------------------------
 This is crazy:
 {{{
 sage: import gc
 sage: A = at_least
 sage: pre = gc.get_objects()
 sage: K = Qp(7,2)
 sage: post = gc.get_objects()
 sage: len(post) - len(pre)
 747
 }}}
 Much of that is empty lists:
 {{{
 sage: M = []
 sage: for a in post:
 ....:     for b in pre:
 ....:         if a is b:
 ....:             break
 ....:     else:
 ....:         M.append(a)
 sage: from collections import defaultdict
 sage: types = defaultdict(int)
 sage: for a in K.M:
 ....:     types[type(a)] += 1
 sage: print '\n'.join([str(a) + ' ' + str(types[a]) for a in types.keys()
 if types[a] > 1])
 <type 'list'> 554
 <type 'tuple'> 57
 <class 'weakref.KeyedRef'> 28
 <type 'weakref'> 22
 <type 'dict'> 18
 <type 'sage.structure.coerce_dict.MonoDictEraser'> 10
 <type 'sage.structure.coerce_dict.MonoDict'> 10
 <type 'cell'> 8
 <type 'instancemethod'> 6
 <type 'frame'> 6
 <type 'sage.structure.coerce_dict.TripleDict'> 5
 <type 'sage.structure.coerce_dict.TripleDictEraser'> 5
 <type 'function'> 4
 <type 'staticmethod'> 4
 <class 'sage.structure.dynamic_class.DynamicMetaclass'> 4
 <class 'sage.rings.homset.RingHomset_generic_with_category'> 2
 <class '_ast.Name'> 2

 sage: listlens = defaultdict(int)
 sage: for a in M:
 ....:     if isinstance(a, list):
 ....:         listlens[len(a)] += 1
 sage: sage: sorted(listlens.items())
 [(0, 525), (1, 9), (2, 2), (3, 2), (23, 10), (53, 5), (116583, 1)]
 }}}
 I'm not sure where these 525 empty lists are created, but it seems a bit
 excessive.

 It's not just p-adic fields:
 {{{
 sage: pre = gc.get_objects()
 sage: K = QuadraticField(-11)
 sage: post = gc.get_objects()
 sage: len(post) - len(pre)
 1152
 }}}

--
Ticket URL: <http://trac.sagemath.org/ticket/15367>
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