Terminology: "reference" versus "pointer"

Rustom Mody rustompmody at gmail.com
Sun Sep 13 02:28:06 CEST 2015

On Sunday, September 13, 2015 at 5:32:44 AM UTC+5:30, Ned Batchelder wrote:
> 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.

Yes that "because" can be ridiculous/disingenuous.
Good deal of it in this thread itself.

Consider int.
Say there are 10,000
int something_or_other;
in the CPython sources

Out of these say 50 are the direct implementation python's int
The remaining 9950 C-ints have no direct correlate with python's int.

The disingenuous reasoning is some kind of statistical argument of 10,000 vs 50.
The reasonable reasoning is that only those 50 are relevant to the discussion.

Likewise pointers

If one were to trace the semantics of looking up a variable in CPython,
one would find some C code doing pointer dereferencing.

One would also find zillions of other uses of pointers that have no direct
correlate to python's variables.

What of it?

If I were to be more technically correct than saying
"Python's variables are C-pointers"

I could say something like:

"Python variables are C pointers with much stronger data-structure 
invariants related to ownership. And implemented with ref-counting, gc etc
as scaffolding to ensure them.  These stronger invariants make impossible in python common C errors like null-pointer referencing. The corresponding cost
of these stronger invariants is that C's pointer type is rendered un-first-class in python"

More information about the Python-list mailing list