[Python-Dev] Memory size overflows

Tim Peters tim.one@comcast.net
Sat, 19 Oct 2002 23:39:08 -0400


[Tim\
>> If you've actually got the energy to time these things <wink>, how
>> about adapting the int-mul overflow checking code in Python's
>> intobject.c's int_mul() function too?

[Gerald S. Williams]
> I'll take a look.

Thanks!

>> It could be simplified a little if it were specialized to unsigned
>> mult.

> You're simply referring to breaking down the operation into "remove
> sign", multiply, and "generate sign" stages, right? I'll definitely
> keep it in mind.

Goodness no -- that kind of cleverness is usually buggy, and usually by
failing to account for that the moral equivalent of -sys.maxint-1 is a fine
product, but sys.maxint+1 isn't.  I was talking specifically about the
based-on-doubles int_mul().  In particular, the slow-path line

		const double absprod = doubleprod >= 0.0 ? doubleprod :
							  -doubleprod;

isn't needed if we know the product is >= 0.