Chris Angelico <[email protected]>:
> On Thu, Mar 3, 2016 at 12:39 AM, Marko Rauhamaa <[email protected]> wrote:
>> Chris Angelico <[email protected]>:
>>
>>> Python defines that every object has an identity, which can be
>>> represented as an integer. Since this is an intrinsic part of the
>>> object, no two distinct objects can truly have identical
>>> characteristics. Python's objects are like rifles - there are many
>>> like it, but this one is mine.
>>
>> How can you be sure Python isn't returning the same id value for two
>> distinct objects?
>
> The same way I can be sure about anything else in Python. It's a
> language guarantee.
Actually, my question is (intentionally) nonsensical.
The sameness or distinctness of two objects is not directly defined in
Python. The definition is simply:
Two objects X and Y are called identical if
X is Y
evaluates to a true value.
Additionally, we have:
If objects X and Y are identical, it is guaranteed that
id(X) == id(Y)
evaluates to a true value.
Even more strongly, we have:
For any objects X and Y,
id(X) == id(Y) if X is Y else id(X) != id(Y)
evaluates to a true value.
What is missing is the rules that are obeyed by the "is" operator.
Marko
--
https://mail.python.org/mailman/listinfo/python-list