ben+python at benfinney.id.au
Wed Mar 5 07:20:46 CET 2014
Rustom Mody <rustompmody at gmail.com> writes:
> That python is a hll means that machine reprs are intended to be abstracted
> away. 'is' fails to do that -- proof of that being the discrepancy between
> is and ==
That's your proof? That is a non sequitur. Those two operators are
*designed to be* different, to compare different things.
How does the difference between ‘==’ versus ‘is’, which are designed and
documented to have different behaviour, lead to your assertion of a
You have yet to respond to this question asked several times:
> > Can you explain what machine representations are leaked into Python
> > by the is operator?
So, what machine represenatation is leaked?
I'll re-iterate that “memory location of the object” isn't a valid
response. There is no necessary relation between the memory location of
the object referenced by “foo” and the return value of ‘id(foo)’. The
latter is useable with utter ignorance of the concept of memory
location, so it is not a leaky abstraction.
Note that for an abstraction to be leaky, the programmer must *be
required* to have an understanding of what lies beneath the abstraction.
If the values that the programmer deals with can be dealt with entirely
at the level of the abstraction, and no knowledge of what's under the
hood is needed, then the abstraction does not leak.
> No claim even remotely to having a clue to metaphysical being that
> python's 'is' implies
Yes, exactly. You have no need to know what is under the hood: it is the
object's identity, which is simply a property which is unique to that
object among all other concurrently-existing objects.
The value returned by ‘id(foo)’ and compared by ‘is’ means nothing else
other than the abstraction of “object identity”. The value has to be
*something*, so it may resemble other things – such as the object's
memory location, or not – but that resemblance is not promised by
anything, and is irrelevant to the user of the abstraction.
\ “As far as the laws of mathematics refer to reality, they are |
`\ not certain, and as far as they are certain, they do not refer |
_o__) to reality.” —Albert Einstein, 1983 |
More information about the Python-list