[Python-Dev] Memory size overflows
Scott Gilbert
xscottg@yahoo.com
Tue, 15 Oct 2002 20:41:20 -0700 (PDT)
[Tim Peters]
>
> I'll repeat that it's hard to do this correctly and quickly (c.f. earlier
> comments about the history of Python's subtly buggy attempts).
>
[...]
>
> 0x01ff *
> 0x00ff
> ------
> 0000
> 00ff
> 0000
> fe01
> --------
> 0001fd01
> ^ oops
>
That was sloppy on my part. Thanks for showing me my error. (That's as
gracious as I can be while saying "D'Oh!" on the inside. :-)
Clearly you know the long answer to this problem. It could involve taking
the ugly expression I had and adding 3 more terms to see if it adds up to a
problem. Or if all those integer multiplies make it less attractive than
just going to double, then taking the log2() of each operand and counting
the bits to see if there is a problem. Or using the PyLong_* machinery.
Or something similar. And you've got your fast path past the test for the
common case, so it looks like you're just hesitant to make the big ugly
macro...
__________________________________________________
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com