[Python-Dev] Re: Suggested memory API rules for 2.3

Neil Schemenauer nas@python.ca
Wed, 3 Apr 2002 07:16:19 -0800


Tim Peters wrote:
> Guido and I sat down and hashed this out Tuesday afternoon.  Here's what I
> think Revealed Truth was.

Very good.  Spelling out the rules was long overdue.

> Note that the eight ways to spell "free" all have to map to the pymalloc
> free when pymalloc is enabled in 2.3.  There is no way to spell "give me the
> raw platform free(), damn it", except for "free".

I guess we need to do something special for pymalloc free() if
PYMALLOC_DEBUG is defined.

> We don't promise anything about the internals of the object allocator.

Good.  Someone might write platform specific versions that use mmap or
something.

>     Recommended Practice
> 
>     When backward compatibility is not a concern, using this subset of
>     the raw memory and object memory APIs is recommended:
> 
>     PyMem_{Malloc, Realloc, Free}
>     PyObject_{Malloc, Realloc, Free}
>     PyObject_{New, NewVar}

This should probably come up front in the documentation.  All the rest
is historical crap. :-)

  Neil