There is some very bad behaviour related to CachedRepresentation caching
that I'm observing on #24742 (but this is otherwise unrelated to that
ticket):
sage: timeit('MatrixSpace(ZZ,3,3)')
625 loops, best of 3: 117 µs per loop
Now, we try again but we first create a strong reference:
sage: S = MatrixSpace(ZZ,3,3)
sage: timeit('MatrixSpace(ZZ,3,3)')
625 loops, best of 3: 4.13 µs per loop
This is much faster the second time! In the first example, the caching
of CachedRepresentation.__classcall__ is pointless since there is no
strong reference to the entry in the cache, so it gets deleted
immediately whenever the "MatrixSpace(ZZ,3,3)" is deleted.
This is just the usual Py_DECREF of Python objects, it has nothing to do
with the cyclic garbage collector: the behaviour remains the same even
with gc.disable().
This makes me think that we might need a version of CachedRepresentation
which keeps semi-strong references: these would only be deleted by the
cyclic garbage collector but not by a simple Py_DECREF().
Jeroen.
--
You received this message because you are subscribed to the Google Groups
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.