Terminology: "reference" versus "pointer"

Ned Batchelder ned at nedbatchelder.com
Sun Sep 13 02:02:26 CEST 2015

On Saturday, September 12, 2015 at 7:15:18 PM UTC-4, Mark Lawrence wrote:
> On 12/09/2015 23:34, rurpy--- via Python-list wrote:
> > On 09/12/2015 04:14 PM, Emile van Sebille wrote:
> >> On 9/12/2015 12:58 PM, rurpy--- via Python-list wrote:
> >>
> >>> The question is whether what "pointer" means in languages that use the
> >>> word is*so*  different than its meaning in the Python sense
> >>
> >> I can't find a single reference to pointer in the python docs outside
> >> of ctypes.  What is its python sense?
> >
> > I should have said "proposed sense" (except I don't really mean
> > proposed as in "let's change all the docs" but as "let's stop the
> > hissy-fits when someone uses the term"), i.e. the way I, I think
> > random832, and others use it re python. Sorry, I see in retrospect
> > my phrasing could be confusing.
> >
> The "hissy-fits" are caused because Python the language does not have 
> pointers, so by definition there is no need to mention them in any way, 
> shape or form in any Python thread.  What is so difficult to understand 
> about that?  I would say it's not rocket science, but the insurers that 
> paid out over Ariane 5 maybe wouldn't be too happy with that.
> -- 
> My fellow Pythonistas, ask not what our language can do for you, ask
> what you can do for our language.
> Mark Lawrence

After all the discussion here, it seems a bit disingenuous to flatly say
that Python has no pointers, and to dismiss people's debate about it.

Pointers are not a simple concept.  In a language like C, they have a 
number of aspects, some of which are apparent in the Python world, and
some of which are not.

Python names refer to values, and this behavior is clearly related to
pointers under the hood.  Whatever Python implementation you are talking
about, a Python name must have some way to indicate what value it refers
to.  In CPython, this is implemented with a pointer.  This is what people
mean when they say that of course Python has pointers.

But in C, pointers mean more than that.  You can perform arithmetic on
them, to access memory as a linearly addressed abstraction.  Python has
nothing like this.

In C, a pointer can refer to another variable.  Again, Python has
nothing like this.  Python names refer to values, but they cannot
refer to other names.

These last two reasons are why people say that Python does not have

As a language concept, Python has no pointers, because you cannot have
names referring to names, and because you cannot perform arithmetic on
references.  The references from names to values are not things that can
be manipulated themselves.

In its implementation, CPython uses pointers.  But if you say that Python
has pointers because CPython uses pointers, then you might as well say
that Python is statically typed because the CPython source has type
declarations.  It's a confusion of implementation and language to conflate
these two.


More information about the Python-list mailing list