id,summary,reporter,owner,description,type,status,priority,milestone,component,resolution,keywords,cc,merged,author,reviewer,upstream,work_issues,branch,commit,dependencies,stopgaps
12357,Make groupoids garbage collectable,SimonKing,rlm,"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
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
}}}
Superseded by #12313.",defect,closed,major,sage-duplicate/invalid/wontfix,memleak,duplicate,groupoid cache Cernay2012,nthiery jpflori,,,"Simon King, Jean-Pierre Flori",N/A,,,,"#715, #11521, #12313, #11943",