[Python-Dev] Make the stable API-ABI usable (original) (raw)
Serhiy Storchaka storchaka at gmail.com
Sun Nov 19 06:50:07 EST 2017
- Previous message (by thread): [Python-Dev] Make the stable API-ABI usable
- Next message (by thread): [Python-Dev] Make the stable API-ABI usable
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
19.11.17 12:59, Antoine Pitrou пише:
On Sun, 19 Nov 2017 00🔞28 +0100 Victor Stinner <victor.stinner at gmail.com> wrote:
Le 18 nov. 2017 10:44, "Serhiy Storchaka" <storchaka at gmail.com> a écrit :
The simplest way to do this: #define PyTupleGETITEM PyTupleGetItem 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. PyTupleGetItem() checks its arguments and raises an error if you pass it something else than a tuple, or if the index is out of bounds. PyTupleGETITEM(), 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);
- Previous message (by thread): [Python-Dev] Make the stable API-ABI usable
- Next message (by thread): [Python-Dev] Make the stable API-ABI usable
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]