[Patches] PyMem [1/8] - Memory API: Summary
Sun, 30 Apr 2000 21:39:24 +0200 (CEST)
Second (and hopefully, final) round of patches relative to the malloc
cleanup and the renewed memory interfaces. It affects *lots* of files
in the distribution -- more than enough for May 1st ;-)
I hereby send a patch per directory to easy their review, except the
two key include files, mymalloc.h and objimpl.h which are to be saved
as is (better than a context diff for Include/* anyway).
Each memory interface exports both functions and macros. Functions
preserve binary compatibility of the code across different releases
while MACROS trade it for speed.
Public API Functions MACROS
-------------- ---------------------------- --------------------
1) Core Memory Allocator (see mymalloc.h)
- raw mem malloc PyMem_Malloc/Realloc/Free PyMem_MALLOC/REALLOC/FREE
- type-oriented PyMem_New/Resize/Del PyMem_NEW/RESIZE/DEL
2) Core Object Memory Allocator & Facilities (see objimpl.h)
- object malloc PyObject_Malloc/Realloc/Free PyObject_MALLOC/REALLOC/FREE
- initialization PyObject_Init/InitVar PyObject_INIT/INIT_VAR
- constr./destr. PyObject_New/NewVar/Del PyObject_NEW/NEW_VAR/DEL
All APIs operate on the Python heap(s). Objects that are subject to custom
allocation strategies (custom = non Python = std malloc, C++ new, 3rd party)
are out of bounds -- we can't do much about them from Python except providing
handy macros related to their structure. The extension-type developer is
responsible for their allocation/deallocation with the malloc of choice.
See the comments in objimpl.h
I tend to be slightly verbose :-) so if you think the comments in the source
can be shortened (or improved) for clarity, you're welcome..
Needless to say, once checked in, a complete overhaul of the Python memory
interfaces would be in place. I encourage you to take some time reviewing
your favorite files in the distribution and see how and why they have
changed. More specific comments follow for each part of the patch suite.
Vladimir MARANGOZOV | Vladimir.Marangozov@inrialpes.fr
http://sirac.inrialpes.fr/~marangoz | tel:(+33-4)76615277 fax:76615252