[Python-Dev] C API for gc.enable() and gc.disable()
Greg Ewing
greg.ewing at canterbury.ac.nz
Fri Jun 27 02:11:00 CEST 2008
Jeff Hall wrote:
> I mistakenly thought that was
> because they were assumed to be small. It sounds like they're ignored
> because they're automatically collected and so they SHOULD be ignored
> for object garbage collection.
Strings aren't tracked by the cyclic garbage collector
because they don't contain object references and therefore
can't form part of a cycle.
However, unless I'm mistaken, allocations and deallocations
of them are still counted for the purpose of determining
when to perform a cyclic GC pass. So if you allocate lots
of strings and they aren't getting deallocated, a cyclic
GC pass will eventually occur, in case the strings are
being referenced from a cycle that can be cleaned up.
I don't know whether/how re uses string objects internally
while it's matching, so I can't say what its garbage
collection characteristics might be when matching against
a huge string.
The behaviour you observed might have been due to the
nature of the re being matched -- some res can have
quadratic or exponential behaviour all by themselves.
--
Greg
More information about the Python-Dev
mailing list