osdir.com


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

About the implementation of del in Python 3


Chris Angelico <rosuav at gmail.com>:

> On Fri, Jul 7, 2017 at 7:15 PM, Marko Rauhamaa <marko at pacujo.net> wrote:
>> You can only define the semantics of Python (in this case) by
>> providing an *arbitrary* mapping to an imaginary abstract machine.
>> There's no way to define the objective abstraction.
>
> So aside from an artificial sense of purity, what's the point in
> defining object identity *at all*? Why invent an arbitrary number that
> you can't even see?

Without such an invisible identity, you can't specify the desired
behavior of a Python program. (Well, id() returns a visible identity,
which you could equate with the invisible one.)

I understand that not everything should be strictly formal, but all
attempts at clarifying Python's object system necessarily involve
evoking some silly abstract model.

The Lisp community is so old they never thought of shunning hardware
concepts (storage, pointers, Common Address Register, Common Data
Register etc). There doesn't seem to be any better way for Python,
either.

It might be easiest to say that every Python object has an address and
id() returns it. Even if you were lying, nobody would be able to call
your bluff. Then, explaining objects to newcomers would be a bit more
straightforward.


Marko