osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

About the implementation of del in Python 3


On Thu, Jul 6, 2017 at 7:24 PM, Marko Rauhamaa <marko at pacujo.net> wrote:
> While talking about addresses might or might not be constructive, let me
> just point out that there is no outwardly visible distinction between
> "address" or "identity".
>
> Equally well, we could replace those words with:
>
>    serial number
>
>    fixed asset tag
>
>    social security number
>
>    fermionic quantum state
>
>    face
>
>    fingerprint
>
>    cryptographic hash

Not so. An address is a place where you can look for something. If you
go to 51 Franklin Street, Boston, MA, USA, you should find the offices
of the Free Software Foundation. That wouldn't be the case if you go
to the FSF's serial number or fermionic quantum state. And a
cryptographic hash is a function of something's value, not its
identity; two identical strings have the same hash, even if they are
unique objects.

> Ignoring the word that is used to talk about object identity, it would
> be nice to have a precise formal definition for it. For example, I know
> that any sound implementation of Python would guarantee:
>
>     >>> def f(a): return a
>     ...
>     >>> a = object()
>     >>> a is f(a)
>     True
>
> But how do I know it?

The formal definition is that objects have identities, and that
assignment (including function parameters and return values) gives you
a reference to the same object.

"A person just walked into the revolving door and came back out again."
"Is it the same person?"
"I don't know. What's the definition of identity?"

Of course it's the same person. You don't need to identify that person
by a social security number in order to say "the SAME PERSON came back
out". You identify him/her by... identity.

ChrisA