[issue21233] Add *Calloc functions to CPython memory allocation API

STINNER Victor report at bugs.python.org
Sun May 4 01:00:51 CEST 2014


STINNER Victor added the comment:

>    "allocate nbytes elements of size 1"

PyObject_Malloc(100) asks to allocate one object of 100 bytes.

For PyMem_Malloc() and PyMem_RawMalloc(), it's more difficult to guess, but
IMO it's sane to bet that a single memory block of size bytes is requested.

I consider that char data[100] is a object of 100 bytes, but you call it
100 object of 1 byte.

I don't think that using nelem or elsize matters in practice.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21233>
_______________________________________


More information about the Python-bugs-list mailing list