Re: [ctypes-users] PYFUNCTYPE, py_object and reference counting
by Lenard Lindstrom other posts by this author
Nov 24 2006 2:01PM messages near this date
Re: [ctypes-users] PYFUNCTYPE, py_object and reference counting
|
Re: [ctypes-users] PYFUNCTYPE, py_object and reference counting
On 21 Nov 2006 at 19:48, Thomas Heller wrote:
> Lenard Lindstrom schrieb:
> > Forgive me if this has been discussed before. For Python api
> > functions does ctypes assume a py_object return type is a new
> > reference and a py_object argument is a borrowed reference?
> > PyList_GetItem returns a borrowed reference. PyList_SetItem steals a
> > reference. I see no reason to call these functions directly. However,
> > since they are accessible from ctypes it makes sense that either it
> > can handle them correctly or they are documented as unsafe to use.
>
> py_object works in the way that one would expect with functions returning
> new references, and *not* stealing a refcount from the argument.
> For other functions it is required to adjust the refcount manually
> with _ctypes.Py_INCREF and _ctypes.Py_DECREF.
>
> When I have time I will document that; patches would of course also
> be appreciated.
>
Patch submitted to ctypes at sourceforge.
Lenard Lindstrom
<len-l@[...].net>
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
ctypes-users mailing list
ctypes-users@[...].net
https://lists.sourceforge.net/lists/listinfo/ctypes-users
Thread:
Lenard Lindstrom
Thomas Heller
Lenard Lindstrom
Thomas Heller
|