#12357: Make groupoids garbage collectable
-------------------------+--------------------------------------------------
Reporter: SimonKing | Owner: rlm
Type: defect | Status: new
Priority: major | Milestone: sage-5.0
Component: memleak | Keywords:
Work_issues: | Upstream: N/A
Reviewer: | Author: Simon King
Merged: | Dependencies: #12313
-------------------------+--------------------------------------------------
Currently, the groupoid of an object P can not be garbage collected, even
when deleting P.
Even worse: The persistence of `Groupoid(P)` also prevents P from being
garbage collected.
The attached patch aims at solving it: An external reference to either P
or `Groupoid(P)` is enough to keep both alive. But without an external
reference, both P and `Groupoid(P)` become collectable.
Example from the docs:
{{{
sage: P = GF(151)['x','y']
sage: n = id(Groupoid(P))
sage: import gc
sage: _ = gc.collect()
sage: n == id(Groupoid(P)) # indirect doctest
True
Thus, the groupoid is cached. But when deleting ``P``, its
groupoid can be garbage collected as well::
sage: del P
sage: _ = gc.collect()
sage: P = GF(151)['x','y']
sage: n == id(Groupoid(P))
False
TESTS:
We test against some corner cases::
sage: Groupoid(None)
Traceback (most recent call last):
...
TypeError: Groupoid of None is not defined
sage: Groupoid(1)
Traceback (most recent call last):
...
TypeError: 1 must either allow attribute assignment or be
instances of <type 'sage.structure.parent.Parent'>
sage: class A: pass
sage: a = A()
sage: Groupoid(a)
Groupoid with underlying set <__main__.A instance at ...>
sage: Groupoid(a) is Groupoid(a)
True
}}}
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12357>
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.