[Python-Dev] PEP 445 delegate

Victor Stinner victor.stinner at gmail.com
Fri Jun 21 22:43:58 CEST 2013


2013/6/21 Antoine Pitrou <solipsis at pitrou.net>:
> I've been appointed PEP 445 delegate by Nick and Guido. I would like to
> know if there are still pending changes to the PEP.


Hum, there is maybe something. In my pytracemalloc project, I added
another API to track usage of free lists:

PyAPI_FUNC(int) _PyFreeList_SetAllocators(
    void (*alloc) (PyObject *),
    void (*free) (PyObject *)
PyAPI_FUNC(void) _PyFreeList_Alloc(void *);
PyAPI_FUNC(void) _PyFreeList_Free(void *);

Then I'm using Py_TYPE(op)->tp_basicsize to get the size of the object.

I didn't add this API to the PEP because I'm not really convinced that
is useful. I wrote it becase Python 2 has unlimited free lists,
especially for the int type. In Python 3, the situation is different:
free lists have a limited size, and the "int" type of Python 3 is the
old "long" type, and int in Python 3 does not use a free list. (By the
way, it may provide better performances if we had a free list for
"small" ints.)

I expect better results with the new PyMem_RawMalloc() function and
the "Don't call malloc() directly anymore" section of the PEP than
with tracking free lists.

I'm testing Python 3.4 with all patches related to the PEP 445 (#3329,
#16742, #18203) and it works fine. You can also try my pytracemalloc
project with its "userdata" branch. I just found a bug in
pytracemalloc for allocation of zero bytes :-)


More information about the Python-Dev mailing list