[Python-Dev] Add Py_off_t and related APIs?

Nick Coghlan ncoghlan at gmail.com
Tue Jan 13 21:21:39 CET 2009

Antoine Pitrou wrote:
> Martin v. Löwis <martin <at> v.loewis.de> writes:
>> -1. How many functions actually require that type?
> Functions in the IO lib. I can't tell you how many, let's say a dozen.
>>> (the motivation is systems where Py_ssize_t is 32-bits wide, but large file
>>> support makes off_t 64 bits wide)
>> For argument parsing, you should use "long long" if SIZEOF_OFF_T is 8
>> and long long is supported, and then assign to off_t as appropriate.
> It's wrong, because floats would be accepted as argument to the seek() method.
> Hence the need for (at least) PyNumber_AsOff_t.
> (of course the IO lib can have its own private implementation of
> PyNumber_AsOff_t. But then why not make it benefit everyone?)

If the IO lib file support is solid, file access code will generally be
using that API and not need to worry about the vagaries of off_t

I'd say start with the private version in IO lib, and then if there is
demand consider moving it to abstract.h (but, like Martin, I don't
expect such demand to ever develop).


* As another step is made on the road to version independent C extensions...

Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-Dev mailing list