[Python-Dev] [Python-checkins] r41972 - python/branches/ssize_t/Objects/funcobject.c

Tim Peters tim.peters at gmail.com
Mon Jan 9 18:48:41 CET 2006


...

[Tim]
>> That's no more or less painful than using C99's huge pile of PRId8,
>> PRId16, PRId32 (etc, etc) macros, defined there for similar purposes.

[Martin]
> Right - and I consider them just as painful.
>
> If you believe that this is really what we should be doing, then, well,
> let's do it.

I think it's clear that in a 64-bit world, we absolutely need a way to
format 64-bit integers.  I'm dubious that Neil's specific line of code
needed Py_ssize_t to begin with, but increasing amounts of other code
will.

Maybe this wasn't clear:  I think Neil's code _should_ be able to put
"%zd" in the format string, not using format macros at all.  IOW, I
believe the supporting routines for PyErr_Format() and
PyString_Format() should be taught to recognize the C99-standard "z"
qualifier and implement its semantics in a platform-correct way. 
That's where the irritating macros would be used, _inside_ the
implementations of Py{Err,String}_Format().  Code passing a Py_ssize_t
to one of those would just use "%zd" directly in its format string,
and on all platforms.

It's only code calling printf/fprintf/sprintf directly with a
Py_ssize_t or size_t output value that would need to use the format
macros, and I don't think there's a lot of that -- looks like most
relevant messages are constructed by Py{Err,String}_Format().


More information about the Python-Dev mailing list