K
karmadharma
Hello everybody
I am trying to make sure that my (non trivial) C module is cleaning up
properly after itself, and consequently I've built python with
--py-debug which, besides allowing me to use certain functions, it also
prints the reference count at the end.
I am finding, however, that the reference count on exit seems to
increase by 1 every time I create one of my objects, poring over the
output of the debugging functions seems to imply that the only thing
that changes is the refcount of
[somenumber] '<dummy key>'
where somenumber seems proportional to the number of objects I create,
if I create n+1 objects, somenumber increases by 1. Looking at the docs
this seems related to empty dictionaries, but I'm really stumped at the
moment.
Out of curiosity I also did this stupid test thinking it would return
the same refcount, but evidently it doesn't:
Type "help", "copyright", "credits" or "license" for more information.
[6606 refs]
Type "help", "copyright", "credits" or "license" for more information.
[6608 refs]
as you can see just assigning another variable causes the refcount to
remain higher when python exits.
Is this something I should be worried about at all? I am new to writing
python C extensions, and that's why I never really worried about all
this before; apologies if my question is obvious and/or trivial...
I am trying to make sure that my (non trivial) C module is cleaning up
properly after itself, and consequently I've built python with
--py-debug which, besides allowing me to use certain functions, it also
prints the reference count at the end.
I am finding, however, that the reference count on exit seems to
increase by 1 every time I create one of my objects, poring over the
output of the debugging functions seems to imply that the only thing
that changes is the refcount of
[somenumber] '<dummy key>'
where somenumber seems proportional to the number of objects I create,
if I create n+1 objects, somenumber increases by 1. Looking at the docs
this seems related to empty dictionaries, but I'm really stumped at the
moment.
Out of curiosity I also did this stupid test thinking it would return
the same refcount, but evidently it doesn't:
Type "help", "copyright", "credits" or "license" for more information.
[17214 refs]a=1 [17214 refs]
(ctrl-D)
[6606 refs]
Type "help", "copyright", "credits" or "license" for more information.
[17217 refs]a=1 [17214 refs]
b=2 [17217 refs]
(ctrl-D)
[6608 refs]
as you can see just assigning another variable causes the refcount to
remain higher when python exits.
Is this something I should be worried about at all? I am new to writing
python C extensions, and that's why I never really worried about all
this before; apologies if my question is obvious and/or trivial...