64-bit ints <-> PyLongs?

Tim Peters tim_one at email.msn.com
Fri Oct 27 20:12:05 EDT 2000


[Kalle Svensson]
> I'm writing a wrapper around a C library where some functions return,
> or expect as arguments, 64-bit ints. Will PyLong_*LongLong work on
> win32 (and preferably Mac too), and is LONG_LONG guaranteed to
> be at least 64 bits.

[Trent Mick]
> ...
> I am not sure if LONG_LONG is guaranteed to be 64-bits but I am
> pretty sure that that is a safe assumption (Tim Peters will probably
> correct  me on that).

I won't let anyone sneak code into Python that defines LONG_LONG to
something *smaller* than 64 bits, so, ya, you can count on that much.
Except:

> The problem is not every platform will HAVE_LONG_LONG (though, again,
> most common ones do).

Aye, that's the rub.  C89 doesn't guarantee that any integral type is
available that wide.  C99 does, though, so the few compilers that don't
already play along will eventually die out.  Note that C99 does not
guarantee that any integral type has *exactly* 64 bits -- I really meant
"smaller than" above.  Luckily, that's what Kalle was asking about.

Note that pyport.h will eventually grow typedefs (named after the C99
typedefs, but with "Py" at the start) for concepts like "signed integral
type at least 64 bits wide".  And so LONG_LONG will eventually be purged
from the codebase in favor of those.

if-i-had-a-free-second-i'd-do-that-right-now-instead-of-finishing-
    this-stupid-signoff-ly y'rs  - tim






More information about the Python-list mailing list