[Python-Dev] pymemcompat.h & PyMem_New and friends

Michael Hudson mwh@python.net
10 Jun 2002 11:36:30 +0100


Michael Hudson <mwh@python.net> writes:

> /* There are three "families" of memory API: the "raw memory", "object
>    memory" and "object" families.  (This is ignoring the matter of the
>    cycle collector, about which more is said below).

Of course this is an over-simplification.  There is at least one other
family in fairly widespread use in the Python core; the "typed memory
allocator", PyMem_New, PyMem_Resize and PyMem_Del.  Should this family
be listed in pyemcompat.h or subtly discouraged? (I don't think there
are any other options).

I think it should be subtly discouraged, for a couple of reasons:

a) three is a smaller number than four.
b) there is a non-analogy:

       PyMem_Malloc ---> PyMem_New
       PyObject_Malloc ---> PyObject_New

   They do rather different things.
c) I don't think omitting a cast and a sizeof is that much of a win.

I'm not proposing actually taking these interfaces away.

(as a special bonus I won't even mention the fact that we have
PyMem_Resize, PyObject_GC_Resize (only used in listobject.c) but not
PyObject_Resize...)

Cheers,
M.

-- 
  If a train station is a place where a train stops, what's a
  workstation?                            -- unknown (to me, at least)