[Python-Dev] Python's C interface for types

"Martin v. Löwis" martin at v.loewis.de
Thu Feb 1 19:35:58 CET 2007


Nick Maclaren schrieb:
>>>> For 0: hash(+0.0)==hash(-0.0)==hash(0)=hash(0L)=0
>>> Unfortunately, that assumes that equality is transitive.
>> No, but the (transitively closed set of equivalent objects) must have
>> the same hash.  ...
> 
> Er, how do you have a transitive closure for a non-transitive operation?
> 
> I really do mean that quite a lot of floating-point bells and whistles
> are non-transitive.

If so, they just shouldn't use the equal operator (==). == ought to
be transitive. It should be consistent with has().

> You have missed my point, which is extended floating-points effectively
> downgrade the status of the purely numeric comparisons, and therefore
> introduce a reasonable requirement for using a tighter match.  Note
> that I am merely commenting that this needs bearing in mind, and NOT
> that anything should be changed.

If introducing extended floating-points would cause trouble to existing
operations, I think extended floating-points should not be introduced
to Python. If all three of you really need them, come up with method
names to express "almost equal" or "equal only after sunset".

Regards,
Martin


More information about the Python-Dev mailing list