Immutability of Floats, Ints and Strings in Python

Steve D'Aprano steve+python at pearwood.info
Fri Nov 25 07:44:08 EST 2016


On Fri, 25 Nov 2016 10:37 pm, Ned Batchelder wrote:

> And: floats are rarely checked for equality, and very very very rarely
> used as dict keys, so there's no gain by short-circuiting the equality
> check.

You cannot short-circuit the equality check, at least not without giving up
IEEE-754 semantics.

If x is a float, then x == x is not always true.




-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.




More information about the Python-list mailing list