#10963: More functorial constructions
-------------------------------------+-------------------------------------
       Reporter:  nthiery            |        Owner:  stumpc5
           Type:  enhancement        |       Status:  needs_work
       Priority:  major              |    Milestone:  sage-5.13
      Component:  categories         |   Resolution:
       Keywords:                     |    Merged in:
        Authors:  Nicolas M. Thiéry  |    Reviewers:  Simon King, Frédéric
Report Upstream:  N/A                |  Chapoton
         Branch:                     |  Work issues:
   Dependencies:  #11224, #8327,     |       Commit:
  #10193, #12895, #14516, #14722,    |     Stopgaps:
  #13589, #14471, #15069, #15094,    |
  #11688, #13394                     |
-------------------------------------+-------------------------------------

Comment (by nbruin):

 There is a way to "borrow" the trashcan: make sure that some standard
 python
 container type is involved in the chain of deletions. For
 `sage.misc.weak_dict`
 this can be done by modifying `del_dictitem_by_exact_value` to return the
 key
 (so it's more "pop_dictitem") and then in the callback do:
 {{{
 ...
                 v=(del_dictitem_by_exact_value(<PyDictObject *>cself,
 <PyObject *>r, r.key),)
                 del v
 ...
 }}}
 i.e., delete a tuple containing the key rather than the key by itself. The
 tuple
 deallocation routine does participate in the trashcan. Drawbacks:
  - this is a little slower
  - we're doing a memory allocation (creation of a tuple) in a weakref
 callback.
  That's not particularly forbidden, but it can trigger a GC.
 We could do something similar in `MonoDictEraser` etc. to properly solve
 #15069.
 Again, the real solution is for cython to participate in the trashcan.

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