ob_refcnt and Py_BuildValue

Gordon McMillan gmcm at hypernet.com
Mon Oct 11 08:27:49 EDT 1999


Dan wrote:
 
> I'm just learning how to write C extension modules in Python and
> I have a question about the reference counts.  Is there any
> reason Py_BuildValue would output an object with a reference
> count other than 1?  I put together a simple test and when
> building an integer object I get a ob_refcnt value of 4. 

Special case for the positive integers less than 100 - they are 
(quasi) static singletons.

- Gordon




More information about the Python-list mailing list