[Patches] fix hashing take#2 (was: fix float_hash and complex_hash for 64-bit *nix)

Tim Peters tim_one@email.msn.com
Sat, 13 May 2000 22:38:17 -0400


[Guido]
> I didn't write the PyFPE_ patches,

Well, that one's obvious:  a bunch of macros and setjmps and platform
#ifdef'ed code to *provoke* an ill-defined signal <0.5 wink>?  This whole
subsystem is a strained attempt to pretend 754 "never happened", by striving
to make every platform pretend it's a particular pre-754 flavor of Unix.
The less this spreads, the better <wink>.

> but I believe they were done by someone whose experience told
> him *never* to trust that a FP operation won't raise SIGFPE.  He put
> them around almost anything that manipulates floating point.

Appears to me that all existing uses of PyFPE_START_PROTECT etc bracket code
where nothing is known about the input(s), and indeed any exception
whatsoever may happen then.  But in the hashing code, after frexp we know
for certain that the double we're manipulating has absolute value < 1.0, and
it's trivially (honest -- this is obvious from inspection) provable a priori
that all following operations on that cannot raise any IEEE exception other
than "inexact result".  So clogging it with macros would bloat the generated
code and slow it down while buying nothing in return.