On Thu, 9 Jul 2015, Chris Angelico wrote:

The semantics of id() in Python are deliberately nonspecific about any
precise meaning for that number; in CPython (the most common
interpreter) it's the address, but other Pythons use arbitrary
sequential numbers, or other schemes. All that matters is:

1) Every object has an identity.
2) If "x is y", then "id(x) == id(y)"
3) If "x is not y", then "id(x) != id(y)", as long as x and y exist
concurrently.

And yes, Python floats are objects - everything in Python is an
object. In Pike, with floats being value types, the notion of
"identity" might have to be expanded to "bit-pattern", but that's
slightly less ideal, as it could result in two separately-generated
NaNs matching (which otherwise shouldn't happen). But stuffing two
different NaNs into a single mapping is going to be pretty rare.

I think the most useful way to define identity in containers is
    x == y || isnan(x) && isnan(y)
because the NaN payload is not visible from pike.

Reply via email to