[Python-3000] C API for ints and strings
Guido van Rossum
guido at python.org
Sat Sep 8 19:12:00 CEST 2007
On 9/8/07, Marcin 'Qrczak' Kowalczyk <qrczak at knm.org.pl> wrote:
> I see that PyInt_* functions are aliases for PyLong_*. Which ones
> should I use for the long term? There are no PyInt equivalents of
> PyLong_FromLongLong nor PyLong_AsLongLong.
Use PyLong for now. Eventually we may rename them all; then we'll
provide a renaming tool or macros.
> Should I continue to use PyUnicode_* functions for the new str?
Correct. Again, eventually we may rename.
> What is the status of the str8 type? Is it kept temporarily until the
> modules are updated to Python3 str, or it is an official immutable bytes
> type? Its repr uses s'...' syntax which is not supported by the parser.
The problem with its repr() is a hint. ;-) it is a temporary hack
until we don't need it any more. During and after the last sprint,
Neal Norwitz did a lot of work towards getting rid of it, but more
needs to be done. Help is welcome!
> Why is _PyLong_FitsInLong private?
I don't know; perhaps because it doesn't always give the best answer.
> In order to convert a Python3 int to
> another numeric representation, I would like to check if it fits in a C
> long, and convert via a string only if it does not. Should I use
> PyLong_AsLong + PyErr_Occurred?
I think either is fine. _PyLong_FitsInLong() will only get better over time. :-)
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-3000
mailing list