On Mon, Apr 14, 2008 at 6:02 AM, Trent Nelson <[EMAIL PROTECTED]> 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
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to