-
Notifications
You must be signed in to change notification settings - Fork 6
Description
The current API allows a lot of flexibly in how PyObject memory is allocated. It can be statically allocated (non-heap types, for example), allocated with CPython's allocator or allocated with some custom allocator (provided by the extension module). This flexibility must provide some advantages (I'm not really sure what they are exactly) but it also places a pretty significant constraint on the implementation of Python. Typically in a garbage collected language implementation, object memory is allocated by the runtime. For best performance, the garbage collector is intimately familiar or integrated with the object allocator. This can reduce memory overhead per-object and speed up the GC process.
We should decide if this is a required feature of the API. An alternative would be to require that PyObject memory be allocated by the runtime (which is already the case for objects with PyGC_Head). Hopefully people with compelling use cases for custom allocated can comment and explain their situation.