"D'Arcy J.M. Cain" <darcy@druid.net> writes:
> On March 25, 2002 06:18 am, Bernhard Herzog wrote:
> > #if PY_VERSION_HEX < 0x01060000
> > #define PyObject_Del(op) PyMem_Del((op))
> > #endif
>
> I will do that but I wonder what is wrong with the macro?
Because the macros shouldn't be used in extension modules. From
http://python.org/doc/current/api/memoryInterface.html:
In addition, the following macro sets are provided for calling the Python memory allocator directly, without
involvingthe C API functions listed above. However, note that their use does not preserve binary compatibility
accrossPython versions and is therefore deprecated in extension modules.
PyMem_MALLOC(), PyMem_REALLOC(), PyMem_FREE().
PyMem_NEW(), PyMem_RESIZE(), PyMem_DEL().
Apart from that the macros aren't really faster anyway, according to
some posts on python-dev.
> I also note that the Python source was just changed a few days ago in this
> area. It looks like everything is going to effectively use the mem functions
> anyway so this change may not matter eventually.
AFAICT, there hasn't been any final decision on the changes to the
memory API. ISTM that they try to preserve backward compatibility as far
as possible and it does indeed seem that PyMem_Del will still work for
objects allocated with PyObject_New even when pymalloc is enabled, but I
haven't followed the python-dev discussion all that closely, so I may be
wrong. Of course, given that this won't work in current python versions
with pymalloc, switching to PyObject_Del would be better when compiling
with python versions that have it.
Bernhard
--
Intevation GmbH http://intevation.de/
Sketch http://sketch.sourceforge.net/
MapIt! http://www.mapit.de/