19.11.17 12:59, Antoine Pitrou пише:
On Sun, 19 Nov 2017 00:18:28 +0100
Victor Stinner <victor.stin...@gmail.com> wrote:
Le 18 nov. 2017 10:44, "Serhiy Storchaka" <storch...@gmail.com> a écrit :

The simplest way to do this:

#define PyTuple_GET_ITEM PyTuple_GetItem

This will not add new names to ABI. Such defines can be added in a separate
header file included for compatibility.


It is exactly what I am proposing :-)

But those do not have the same semantics.  PyTuple_GetItem() checks its
arguments and raises an error if you pass it something else than a
tuple, or if the index is out of bounds.  PyTuple_GET_ITEM(), however,
will crash if you do so.

There are no guaranties that PyTuple_GET_ITEM() will crash.

In all cases when PyTuple_GET_ITEM() is used for getting the reference to a tuple's item it can be replaced with PyTuple_GetItem().

But if PyTuple_GET_ITEM() is used for getting a reference to a C array of items it can't be replaced with PyTuple_GetItem(). And actually there is no replacement for this case in the limited API.

    PyObject **items = &PyTuple_GET_ITEM(tuple, 0);

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to