[Python-Dev] issues with int/long on 64bit platforms - eg stringobject (PR#306)

Trent Mick trentm@activestate.com
Sat, 29 Apr 2000 11:12:07 -0700


On Sat, Apr 29, 2000 at 02:50:07PM +0200, M.-A. Lemburg wrote:
> Here is another one... I don't really like it because I think that
> silent truncations are a bad idea, but to make things "just work
> it would help:
> 
> * Change PyArg_ParseTuple() to truncate the range(INT_MAX+1, LONG_MAX+1)
>   to INT_MAX and the same for negative numbers when passing a
>   Python integer to a "i" marked variable. This would map
>   range(INT_MAX+1, LONG_MAX+1) to INT_MAX and thus sys.maxint
>   would turn out as INT_MAX in all those cases where "i" is
>   used as parser marker. Dito for negative values.
> 
> With this truncation passing sys.maxint as default argument
> for length parameters would "just work" :-).
> 
> The more radical alternative would be changing the Python
> object length fields to long -- I don't think this is

If we *do* make this change however, say "size_t" please, rather than long
because on Win64 sizeof(long) < sizeof(size_t) == sizeof(void*).

> practical though (and probably not really needed unless
> you intend to work with 3GB strings ;).

I know that 3GB+ strings are not likely to come along but if the length
fields were size_t it would clean up implicit downcasts that you currently
get from size_t to int on calls to strlen and the like on 64-bit systems.


Trent