#12313: Fix yet another memory leak caused by caching of coercion data
--------------------------------------------------+-------------------------
       Reporter:  SimonKing                       |         Owner:              
                             
           Type:  defect                          |        Status:  
needs_review                             
       Priority:  major                           |     Milestone:  sage-5.3    
                             
      Component:  memleak                         |    Resolution:              
                             
       Keywords:  coercion weak dictionary        |   Work issues:              
                             
Report Upstream:  N/A                             |     Reviewers:  Simon King, 
Jean-Pierre Flori, John Perry
        Authors:  Simon King, Jean-Pierre Flori   |     Merged in:              
                             
   Dependencies:  #11521, #11599, #12969, #12215  |      Stopgaps:              
                             
--------------------------------------------------+-------------------------

Comment (by SimonKing):

 For completeness: `IdKeyDict` is also faster than a Python dict, but of
 course that should mainly be true because we are comparing by identity,
 not equality.
 {{{
 sage: from sage.structure.idkey_dict import IdKeyDict
 sage: I1 = IdKeyDict(1,53)
 sage: I3 = IdKeyDict(3,53)
 sage: D1 = {}
 sage: D3 = {}
 sage: L = []
 sage: for p in prime_range(10000):
 ....:     L.append(GF(p)['x','y'])
 ....:
 sage: for i,K in enumerate(L):
 ....:     I1[K] = i
 ....:     I3[K,K,True] = i
 ....:     D1[K] = i
 ....:     D3[K,K,True] = i
 ....:
 sage: K = GF(97)['x','y']
 sage: K2 = GF(next_prime(p))['x','y']
 sage: K in I1
 True
 sage: K in D1
 True
 sage: K2 in I1
 False
 sage: K2 in D1
 False
 sage: (K,K,True) in D3
 True
 sage: (K,K,True) in I3
 True
 sage: %timeit K in D1
 625 loops, best of 3: 720 ns per loop
 sage: %timeit K in I1
 625 loops, best of 3: 560 ns per loop
 sage: %timeit K2 in D1
 625 loops, best of 3: 763 ns per loop
 sage: %timeit K2 in I1
 625 loops, best of 3: 400 ns per loop
 sage: %timeit (K,K,True) in D3
 625 loops, best of 3: 1.53 µs per loop
 sage: %timeit (K,K,True) in I3
 625 loops, best of 3: 1.3 µs per loop
 sage: %timeit (K2,K,True) in D3
 625 loops, best of 3: 1.45 µs per loop
 sage: %timeit (K2,K,True) in I3
 625 loops, best of 3: 555 ns per loop
 sage: %timeit D1[K]
 625 loops, best of 3: 647 ns per loop
 sage: %timeit I1[K]
 625 loops, best of 3: 502 ns per loop
 sage: %timeit D3[K,K,True]
 625 loops, best of 3: 1.48 µs per loop
 sage: %timeit I3[K,K,True]
 625 loops, best of 3: 1.23 µs per loop
 }}}

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12313#comment:171>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to