Chris Angelico wrote:
1) Pointer arithmetic simply doesn't exist in Python. Arrays/lists are
not just pointers to their first elements, and subscripting is most
definitely NOT "add to pointer and dereference".
2) In fact, dereferencing as a whole isn't really a 'thing' either. At
best, it happens automatically.
3) References actually mean something. Copying a pointer doesn't.
Whether the Python you're using is refcounted (CPython) or
mark-and-sweep (uPy, I think) or some other model, an additional
reference to the same object will prevent it from being disposed of,
which isn't the case in C.
4) A pointer is itself a value. You can pass a
pointer-to-local-variable to another function and have that function
change a local variable.
5) Furthermore, since a pointer is a value, you can have pointers to
pointers, etc. Doesn't make any sense in Python.

FWIW, most of those things are peculiar to C, and are not
necessarily shared even with other languages that have
explicit pointers. In Pascal, for example, there is no
pointer arithmetic, and (at least not without nonstandard
extension) you can't make a pointer point into the middle
of a stack frame or array or record, etc. (You *can* have
a pointer to a pointer, but only by heap-allocating a
memory block containing a single pointer, which is not
useful very often).

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to