Re: [Python-Dev] New PEP: Using ssize_t as the index type
by Armin Rigo other posts by this author
Dec 29 2005 9:31AM messages near this date
Re: [Python-Dev] New PEP: Using ssize_t as the index type
|
Re: [Python-Dev] New PEP: Using ssize_t as the index type
Hi Martin,
On Thu, Dec 29, 2005 at 03:04:30PM +0100, "Martin v. L?wis" wrote:
> New conversion functions PyInt_FromSsize_t, PyInt_AsSsize_t,
> PyLong_AsSsize_t are introduced. PyInt_FromSsize_t will transparently
> return a long int object if the value exceeds the MAX_INT.
I guess you mean LONG_MAX instead of MAX_INT, in the event that ssize_t
is larger than a long. Also, distinguishing between PyInt_AsSsize_t()
and PyLong_AsSsize_t() doesn't seem to be useful (a quick look in your
branch makes me guess that they both accept an int or a long object
anyway).
> The conversion codes 's#' and 't#' will output Py_ssize_t
> if the macro PY_SIZE_T_CLEAN is defined before Python.h
> is included, and continue to output int if that macro
> isn't defined.
Hum. It would be much cleaner to introduce a new format character to
replace '#' and deprecate '#'...
> Compatibility with previous Python
> versions can be achieved with the test::
>
> #if PY_VERSION_HEX < 0x02050000
> typedef int Py_ssize_t;
> #endif
>
> and then using Py_ssize_t in the rest of the code.
Nice trick :-)
As far as I can tell you have done as much as possible to ensure
compatibility, short of adding new slots duplicating the existing ones
with the new signature -- which would make abstract.c/typeobject.c a
complete nightmare. I'm +1 on doing this in 2.5.
A bientot,
Armin
_______________________________________________
Python-Dev mailing list
Python-Dev@[...].org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/python-dev-ml%40activestate.c
om
Thread:
"Martin v. Löwis"
Travis E. Oliphant
"Martin v. Löwis"
Brett Cannon
Fredrik Lundh
"Martin v. Löwis"
Tim Peters
"Martin v. Löwis"
Armin Rigo
"Martin v. Löwis"
Armin Rigo
"Martin v. Löwis"
M.-A. Lemburg
Neal Norwitz
"Martin v. Löwis"
M.-A. Lemburg
"Martin v. Löwis"
M.-A. Lemburg
"Martin v. Löwis"
M.-A. Lemburg
"Martin v. Löwis"
Tim Peters
"Martin v. Löwis"
Michael Urman
Neal Norwitz
Aahz
"Martin v. Löwis"
Guido van Rossum
|