[Python-Dev] Highlighting reference-stealing APIs [was Re: cpython: Fix email post-commit review comments.]

"Martin v. Löwis" martin at v.loewis.de
Thu Apr 19 12:59:56 CEST 2012

Am 19.04.2012 12:42, schrieb Sam Partington:
> On 19 April 2012 02:20, Nick Coghlan <ncoghlan at gmail.com> wrote:
>> On Thu, Apr 19, 2012 at 12:21 AM, Antoine Pitrou <solipsis at pitrou.net> wrote:
>>> (and here we see why reference-stealing APIs are a nuisance: because
>>> you never know in advance whether a function will steal a reference or
>>> not, and you have to read the docs for each and every C API call you
>>> make)
>> Yeah, it would have been nice if there was an explicit hint in the API
>> names when reference stealing was involved, but I guess it's far too
>> late now :(
> It's too late to change the fn names sure, but you could change the
> argument names in question for reference stealing apis with some kind
> of markup.

While it may too late to change the names, it's not to late to remove
these functions entirely. It will take some time, but it would be
possible to add parallel APIs that neither borrow nor steal references,
and have them preferred over the existing APIs. Then, with Python 4,
the old APIs could go away.


More information about the Python-Dev mailing list