[Python-3000] longobject.c and Windows x64

Mark Dickinson dickinsm at gmail.com
Tue Apr 15 00:38:59 CEST 2008


On Mon, Apr 14, 2008 at 6:02 AM, Trent Nelson <tnelson at onresolve.com> wrote:

>
> On Windows x64, sizeof(size_t) > sizeof(long), so the existing
> PyLong_FromSsize_t and PyLong_FromSize_t implementations in longobject.c are
> just plain wrong.  I've patched it as follows, but as I'm not well versed in
> the many intricacies of longobject.c, I'd appreciate input from others.
>

I'm missing something:  in what way are the existing implementations
wrong?  I see that the test  (ival < PyLong_BASE) in
PyLong_FromSsize_t should be something like:
(ival < PyLong_BASE && ival > -PyLong_BASE), but
PyLong_FromSize_t looks okay to me.  (Apart from the
unused "int one = 1;", that is.)

I agree that it's a little odd to go via _PyLong_FromByteArray.

Couldn't PyLong_FromSsize_t be written to exactly mimic
PyLong_FromLongLong?  It means duplication of code, I know,
but it also means not relying on ssize_t being equal to either
long or long long.

By the way, I don't much like the handling of negative
values in PyLong_FromLong and PyLong_FromLongLong:
these functions use code like:

if (ival < 0) {
ival = -ival;
negative = 1;
}

which looks to me as though it might mishandle the case
where ival = LONG_MIN.  Should this be fixed?

Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-3000/attachments/20080414/2f837139/attachment.htm 


More information about the Python-3000 mailing list