[Python-Dev] Add Py_off_t and related APIs?

"Martin v. Löwis" martin at v.loewis.de
Tue Jan 13 23:52:45 CET 2009


> Perhaps it would be useful to provide generic support for integer types
> that might have different widths on different platforms?  e.g.:
> 
> uid_t uid = PyNumber_AS_INT_BY_SIZE(number_ob, uid_t);
> 
> That way, the core does not need to know about every blah_t type used by
> POSIX and extension modules, while offering convenient conversion
> functions nonetheless.

I don't think that this would be that useful. What might help is support
for parsing arbitrary-sized integers in PyArg_ParseTuple, as this should
typically be the path through which you get the valud into the (say) uid
variable.

However, it's still then fairly tricky: is uid_t a signed type or an
unsigned type; if unsigned, can I still have negative values (which, for
uid_t, I often can), does the platform have uid_t in the first place,
and, if not, what other type should I use? and so on.

Regards,
Martin


More information about the Python-Dev mailing list