Movatterモバイル変換
[0]ホーム
[Python-Dev] Memory size overflows
Tim Peterstim.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 byfailing to account for that the moral equivalent of -sys.maxint-1 is a fineproduct, but sys.maxint+1 isn't. I was talking specifically about thebased-on-doubles int_mul(). In particular, the slow-path lineconst double absprod = doubleprod >= 0.0 ? doubleprod : -doubleprod;isn't needed if we know the product is >= 0.
[8]ページ先頭