Nick Maclaren schrieb: >> I personally consider *very* important that hash(5.0) == hash(5) (and >> that 5.0 == 5, of course). > > It gets a bit problematic with floating-point, when you can have > different values "exactly 5.0" and "approximately 5.0". IEEE 754 > has signed zeroes. And so it goes.
[not sure what "And so it goes" means in English] It may be a bit problematic to implement, but I think a clean specification is possible. If a and b are numbers, and a==b, then hash(a)==hash(b). I'm not sure whether "approximately 5.0" equals 5 or not: if it does, it should hash the same as 5, if it doesn't, it may or may not hash the same (whatever is easier to implement). For 0: hash(+0.0)==hash(-0.0)==hash(0)=hash(0L)=0 Regards, Martin _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com