[Bf-python] Reference Count Owners Manual
Ken Hughes
khughes at pacific.edu
Wed Sep 21 22:25:33 CEST 2005
Joseph Gilbert wrote:
> Hello to all,
>
> I'm am getting myself clear on reference count in the C/API and i've put
> together a little document to help me :) If anyone would like to
> disscuss it or verify ideas presented here that would be great. I would
> like to use this personally in my coding efforts and if it's useful, to
> also place on the wiki. Anyway without further ado:
This is a good idea; I spend a lot of time reading to see if I've just
been handed a new reference or a borrowed reference. Two brief suggestions:
>...
> C/API Functions beginning with PyObject_, PySequence_, PyMapping_,
> PyNumber_ return references that you own.
Not all of them; some like PySequence_Fast_GET_ITEM() return borrowed
references.
>...
> Functions beginning with PyList_, PyTuple_, PyDict_, etc. return a
> borrowed reference.
Almost all, PyList_New() and the like being exceptions (obviously :-) )
Ken
More information about the Bf-python
mailing list