Re: [Python-Dev] Py_SIZE vs PyXXX_GET_SIZE

2017-03-20 Thread Victor Stinner
We may modify PyXXX_GET_SIZE() to add assert(PyXXX_Check()) to help to detect bugs and misuses of these macros in debug mode. The problem is that I expect a compilation error on PyXXX_GET_SIZE()=size. The new PyDict_GET_SIZE() macro has the assertion. Use Py_SIZE() to set the size. Victor Le 20

Re: [Python-Dev] Py_SIZE vs PyXXX_GET_SIZE

2017-03-20 Thread Benjamin Peterson
On Mon, Mar 20, 2017, at 13:18, Antoine Pitrou wrote: > On Mon, 20 Mar 2017 13:26:34 +0200 > Serhiy Storchaka wrote: > > What is the preferable way of getting the size of tuple, list, bytes, > > bytearray: Py_SIZE or PyTuple_GET_SIZE, PyList_GET_SIZE, > > PyBytes_GET_SIZE, PyByteArray_GET_SIZE

Re: [Python-Dev] Py_SIZE vs PyXXX_GET_SIZE

2017-03-20 Thread Antoine Pitrou
On Mon, 20 Mar 2017 13:26:34 +0200 Serhiy Storchaka wrote: > What is the preferable way of getting the size of tuple, list, bytes, > bytearray: Py_SIZE or PyTuple_GET_SIZE, PyList_GET_SIZE, > PyBytes_GET_SIZE, PyByteArray_GET_SIZE? Are macros for concrete types > more preferable or they are out

Re: [Python-Dev] Py_SIZE vs PyXXX_GET_SIZE

2017-03-20 Thread Brett Cannon
On Mon, 20 Mar 2017 at 04:28 Serhiy Storchaka wrote: > What is the preferable way of getting the size of tuple, list, bytes, > bytearray: Py_SIZE or PyTuple_GET_SIZE, PyList_GET_SIZE, > PyBytes_GET_SIZE, PyByteArray_GET_SIZE? Are macros for concrete types > more preferable or they are outdated? >

[Python-Dev] Py_SIZE vs PyXXX_GET_SIZE

2017-03-20 Thread Serhiy Storchaka
What is the preferable way of getting the size of tuple, list, bytes, bytearray: Py_SIZE or PyTuple_GET_SIZE, PyList_GET_SIZE, PyBytes_GET_SIZE, PyByteArray_GET_SIZE? Are macros for concrete types more preferable or they are outdated? On one hand concrete type macros are longer than Py_SIZE, a