A question on modification of a list via a function invocation

Rustom Mody rustompmody at gmail.com
Tue Sep 5 09:42:34 EDT 2017


On Tuesday, September 5, 2017 at 6:42:07 PM UTC+5:30, Gregory Ewing wrote:
> Steve D'Aprano wrote:
> > The third entity is the reference linking the name to the object (the arrow).
> > This isn't a runtime value in Python, nor is it a compile time entity that
> > exists in source code. It is pure implementation, and as such, exists outside
> > of the Python domain.
> 
> The fact that there is a connection between the name and the
> object is very much part of Python's abstract semantics.
> 
> There are different ways to implement that connection, but
> *any* implementation of Python has to include *some*
> representation of it.
> 
> There are also different words that can be used to describe
> it. You can say that names are bound to objects, or that
> names refer to objects, or that names hold references to
> objects. These are all equally good ways of talking about
> the exact same abstract concept.
> 
> To me this argument about whether Python has references
> or not is like an American person saying that cars have
> hoods, and a British person saying he's wrong, hoods
> are an implementation detail and cars actually have
> bonnets instead.

Also called playing humpty-dumpty

I believe there is a germ of value behind all this empty polemics 
There are 3 equivalence relations:
1. == — mathematical, too coarse to understand nuances of python semantics
2. is — machine representation, too fine to be useful
3. graph (or topological) equality which experienced pythonistas have internalized 
in understanding when two data structures are same or different
[Roughly Anton's diagrams that are beyond my drawing capability!]


And yet pythonistas need that to understand python data structures

>>> a = [1,2]
>>> b = [a,a]
>>> c = [[1,2],[1,2]]
>>> b == c
True
>>> b is c
False
>>> p = [1,2]
>>> q = [p,p]
>>> r = [[1,2],[1,2]]
>>> q == r
True
>>> q is r
False
>>> b == q
True
>>> b == r
True
>>> b is q
False
>>> b is r
False

Now the pythonista understands that b and c may be math-= but have different structure
Whereas b is graph-equal to q
And c is graph-equal to r

However there is no available operation to show/see that distinction

The trouble is that graph-isomorphism is NP-complete so the crucial operation
cannot be reasonably implemented

Let the endless threads continue 😈



More information about the Python-list mailing list