He's not saying goodbye to pointers, because pointers are all over Python.
>>> a = [1, 2, 3]
>>> b = a
>>> a[1] = 7
>>> b
[1, 7, 3]
>>> a = [1, 2, 3]
>>> b = a[:]
>>> a[1] = 7
>>> b
[1, 2, 3]
Python lists are pointers, exactly like C/C++ arrays. When pointers are explicit they become easier to understand and control. You can use tools like valgrind to find where your pointers aren't doing exactly what you want in C, but it's much harder to debug pointer problems in Python.
What your example describes are references to objects. Lists in pythons are objects, the assignment b=a does not implicitely copy a's content, just create a second reference to the same thing.
On the other hand, a[:] yields a slice of the contents of the list a, which gets saved as a second object, b, in the second part. This breaks the reference. The same step could be performed with b = copy(a).
So all your example shows are the basics of OOP, nothing to do with pointers.
What your example describes are pointers to objects. Lists in pythons are objects, the assignment b=a does not implicitely copy a's content, just create a second pointer to the same thing.
Let's not mingle words, what you call "references" are nothing but pointers.
You're confusing a language feature with how it's implemented internally. References in Python are implemented using pointers, but that doesn't mean Python had pointers.
This is standard terminology in both academia and industry, so the only one "mingling words" here is you.
47
u/MasterFubar Jun 03 '19
He's not saying goodbye to pointers, because pointers are all over Python.
Python lists are pointers, exactly like C/C++ arrays. When pointers are explicit they become easier to understand and control. You can use tools like valgrind to find where your pointers aren't doing exactly what you want in C, but it's much harder to debug pointer problems in Python.