rich comparison fscks up reference count?
Gerhard Häring
gerhardhaering at googlemail.com
Mon Apr 12 10:27:05 EDT 2010
Maybe somebody can enlighten me here. I can't figure out why doing a
rich comparison on my object decreases the total reference count by 1.
Linked is the minimal test case with a C exension that compiles under
both Python 2.6 and 3.1. No external dependencies, except a DEBUG
build of Python to see the effect (Py_REF_DEBUG defined).
http://cdn.ghaering.de/foo.c
http://cdn.ghaering.de/setup.py
Builtin types like list, dict, etc. don't seem to have the same
effect.
I've also run the test a few thousand times; then the total refcount
is like -50000, but Python does not crash. Also if I print all objects
and their respective refcounts using the gc module, none of them seems
to have a negative refcount, but the total refcount is still way
negative. How could that be?
-- Gerhard
More information about the Python-list
mailing list