[Python-Dev] Pep 353: Py_ssize_t advice
dave at boost-consulting.com
Sat Sep 23 00:17:13 CEST 2006
"Martin v. Löwis" <martin at v.loewis.de> writes:
> David Abrahams schrieb:
>> #if PY_VERSION_HEX < 0x02050000
>> typedef int Py_ssize_t;
>> #define PY_SSIZE_T_MAX INT_MAX
>> #define PY_SSIZE_T_MIN INT_MIN
>> I just wanted to point out that this advice could lead to library
>> header collisions when multiple 3rd parties decide to follow it. I
>> suggest it be changed to something like:
>> #if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
> Strictly speaking, this shouldn't be necessary. C allows redefinition
> of an object-like macro if the replacement list is identical (for
> some definition of identical which applies if the fragment is
> copied literally from the PEP).
> So I assume you had non-identical replacement list?
a. I didn't actually experience a collision; I only anticipated it
b. We were using C++, which IIRC does not allow such redefinition
c. anyway you'll get a nasty warning, which for some people will be
just as bad as an error
> Can you share what alternative definition you were using?
> In any case, I still think this is good practice, so I added it
> to the PEP.
More information about the Python-Dev