#13394: Write a WeakValueDictionary with safer key removal
-------------------------------------+-------------------------------------
       Reporter:  nbruin             |        Owner:  rlm
           Type:  enhancement        |       Status:  needs_review
       Priority:  major              |    Milestone:  sage-5.13
      Component:  memleak            |   Resolution:
       Keywords:                     |    Merged in:
        Authors:  Simon King         |    Reviewers:
Report Upstream:  None of the above  |  Work issues:
  - read trac for reasoning.         |       Commit:
         Branch:                     |  c3dba989f73c1eec0a66cf72ae203132fe33b5da
  u/SimonKing/ticket/13394           |     Stopgaps:
   Dependencies:                     |
-------------------------------------+-------------------------------------

Comment (by nbruin):

 Replying to [comment:18 SimonKing]:
 > Why is a weak self-reference needed? Is this just to prevent problems
 that could arise when one of the internally used weak references creeps
 out of the dict?

 See [http://bugs.python.org/issue417795]. I'm not convinced by its
 reasoning. Certainly in sage we're already depending on cyclic GC left and
 right, so I don't see the issue (we wouldn't dream of subclassing
 WeakValueDictionary with a `__del__` method). It's also a very old fix,
 probably stemming from a time that people were still suspicious about the
 cyclic GC. If this stuff would get merged in Python, it would probably
 need the weakref, but I don't think it needs it in Sage.

 For iterator stuff: in Python3 this is fixed. See
 [http://hg.python.org/cpython/file/default/Lib/weakref.py] for starters
 (and [http://hg.python.org/cpython/file/default/Lib/_weakrefset.py] for
 `_IteratorGuard`). You probably just want to backport that stuff wholesale
 into your own module.

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