Reference Counting Irregularity

Eric Edmond t-erice at microsoft.com
Thu Jun 25 14:49:00 EDT 2015


Hi,

I have been writing a C++ extension for Python recently, and am currently fixing the reference counting throughout the extension. As I am very new to this topic, my question may have a simple answer, but I was unable to find any mention of the behavior online.

When using the PyObject_GetItem(obj, key) function, I noticed inconsistent behavior with various types of obj (for reference, key is always a str object). When obj is a standard dictionary, the key's reference count remains unchanged, as expected. However, when obj is a pandas DataFrame object, the key's reference count increases by 2. This could very well be by design of the DataFrame object doing some internal caching of the string, but does not appear in the documentation, so I thought I would bring up the issue.

Thanks,

Eric Edmond
University of Michigan | Class of 2016

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20150625/bb8de9ea/attachment.html>


More information about the Python-list mailing list