Ref Count Checking

Robin Becker robin at jessikat.fsnet.co.uk
Thu Aug 30 06:05:38 EDT 2001


In article <4325613.PTg5d078U9 at lunix.schabi.de>, Markus Schaber <markus at schabi.de> writes
>Hi,
>
....
>As Strings are unique, and internalized, may be the module as such 
>(compiled code) contains references to the strings?
>
>markus
well I don't have to do that in my extension and things seem to work fine with the external
results. Perhaps I'm being naive when I do

PyDict_SetItemString(attrs, name, t=PyString_FromString(sValue));
Py_DECREF(t);

ie I haven't interned anything.

Would the module need two extra refs as in

>>> from sys import getrefcount as rc
>>> p={'az1': 99999}
>>> q={'az2': 'az3'}
>>> rc(p['az1']), rc(q['az2'])
(2, 4)
>>> 
-- 
Robin Becker



More information about the Python-list mailing list