#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:                     |  fab0ed4112b9f798e2690f4c885b57cd711ea698
  u/SimonKing/ticket/13394           |     Stopgaps:
   Dependencies:                     |
-------------------------------------+-------------------------------------

Comment (by nbruin):

 Replying to [comment:41 SimonKing]:
 > PS: If this is really the problem, then one could perhaps have
 `self._pending_additions`, and not only `self._pending_removals`.

 Two notes:
  - hash values are `long`. You're using `int` for them in your code in
 some places.
  - I think you might be going overboard a bit with the iteration
 protection. Python dictionaries (and lists) are clearly documented as not
 safe to mutate while iterating over them. Weak dictionaries are a little
 different because you never know if there's a callback triggered by a GC,
 so iterating over a weak dict would never be safe. However, I think the
 ''only'' thing to be guarded against is callbacks during iteration (so
 just defer them and execute them when the guard goes down again). Any
 other mutation is just for the user to live with. Indeed, for debugging,
 you could raise an error if a mutation is attempted while an iterator is
 pending on the thing.

 I'll try and make a weakvaluedict tonight, based on `delete_exact` and see
 how it performs compared to your implementation.

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