Re: Problem with python compile

From: Bernhard Herzog <bh(at)intevation(dot)de>
To: "D'Arcy J(dot)M(dot) Cain" <darcy(at)druid(dot)net>
Cc: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, PostgreSQL-interfaces <pgsql-interfaces(at)postgresql(dot)org>, dwallace(at)udel(dot)edu
Subject: Re: Problem with python compile
Date: 2002-03-25 13:36:52
Message-ID: 6q4rj4hiq3.fsf@abnoba.intevation.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

"D'Arcy J.M. Cain" <darcy(at)druid(dot)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 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().

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/

In response to

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message Jan Wieck 2002-03-25 18:44:11 Re: Checking if a table locked from pl/pgsql
Previous Message D'Arcy J.M. Cain 2002-03-25 12:38:32 Re: Problem with python compile