PyMem_* cross-Python-generation recommendation?

Mike C. Fletcher mcfletch at home.com
Fri Apr 13 23:55:41 EDT 2001


>From the Memory Interface document for Python 2.0, the following is
described:

In addition, the following macro sets are provided for calling the Python
memory allocator directly, without involving the C API functions listed
above. However, note that their use does not preserve binary compatibility
accross Python versions and is therefore deprecated in extension modules.

PyMem_MALLOC(), PyMem_REALLOC(), PyMem_FREE().
PyMem_NEW(), PyMem_RESIZE(), PyMem_DEL().


If I attempt to use PyMem_New in Python 1.5.2, I get a not-defined error,
PyMem_NEW is there.  Conversely, if I attempt to use PyMem_FREE in 1.5.2, I
get a not defined error but PyMem_Free is there.  So, I'm wondering, what
combination should I use for an extension module (PyOpenGL) which requires
compilation for both Python 1.5.2 and 2.x?  Currently I'm just using
PyMem_NEW and PyMem_Free.  That compiles under both Pythons, but I have _no_
clue what the implications of the choice are.

Should I instead do some #define hackery to make 1.5.2 use whatever's
available while making 2.0 to use PyMem_Free and PyMem_New?

Clues for the clueless?
Mike
__________________________________
 Mike C. Fletcher
 Designer, VR Plumber
 http://members.home.com/mcfletch





More information about the Python-list mailing list