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

Old description:

> On ticket #12313 we found that the use of `WeakValueDictionaries` as
> caches can cause `removal` callbacks in rather harsh environments. Normal
> `WeakValueDictionaries` remove keys with dead values by looking up the
> key. This involves Python equality testing on the key, which can cause
> any kind of operation in Sage. We need a dictionary where we can delete
> entries without key comparisons. See below for possible strategies.
>
> '''To the release manager:''' please fold this branch upon merging. There
> is quite a bit of back-and-forth in the history of this branch that is
> not very instructive to have in the global history of sage.

New description:

 On ticket #12313 we found that the use of `WeakValueDictionaries` as
 caches can cause `removal` callbacks in rather harsh environments. Normal
 `WeakValueDictionaries` remove keys with dead values by looking up the
 key. This involves Python equality testing on the key, which can cause any
 kind of operation in Sage. We need a dictionary where we can delete
 entries without key comparisons. See below for possible strategies.

 '''To the release manager:'''

 There is quite a bit of back-and-forth in the history of this branch that
 is not very instructive to have in the global history of sage. Hence, we
 have provided a single patch, if that seems to suite better. Moreover, it
 is in the old folder layout, so that it should be possible to apply before

 Apply [attachment:trac13394-weak_value_dictionary.patch]

--

Comment (by SimonKing):

 I have removed the trailing whitespace from the patch, but not from the
 branch yet (I can do so when requested).

 This patch does apply to sage-5.12.beta5 (that's the latest non-git
 version on my machine). Note that there was a mismatch in
 `sage/structure/factory.pyx`, because someone appears to have removed
 trailing whitespace. It must have happened somehow between sage-5.12.beta5
 and the master branch on trac, but `git blame` does not show how the
 whitespace has vanished.

 Anyway. Nils, please verify that the attached patch applies to some non-
 git Sage, and that the patch does what we do in the branch.

 Apply trac13394-weak_value_dictionary.patch

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