Finding the instance reference of an object

Terry Reedy tjreedy at
Mon Oct 27 23:03:26 CET 2008

gooberts at wrote:
> On Oct 17, 5:39 pm, Joe Strout <j... at> wrote:
>> On Oct 17, 2008, at 3:19 PM, Grant Edwards wrote:

>>> No, it isn't.  In many other languages (C, Pascal, etc.), a
>>> "variable" is commonly thought of as a fixed location in memory
>>> into which one can put values.  Those values may be references
>>> to objects.

In particular, memory is a linear sequence of writable cells.  In Turing 
machines, they have no address, and access is by one-at-a-time movement. 
  Subsequently, cells were given count addresses 0, 1, 2, ... .

>> Right, though not in languages like C and Pascal that don't HAVE the  
>> notion of objects.  We really ought to stop bringing up those  
>> dinosaurs and instead compare Python to any modern OOP language.
>>>  In Python, that's not how it works.  There is no
>>> "location in memory" that corresponds to a variable with a
>>> particular name the way there is in C or Pascal or Fortran or
>>> many other languages.
>> No?  Is there any way to prove that,

The burden of proof is on those who claim a positive.  Grant and I claim 
that there is no pink elephant in the room, and that we have looked 
around pretty thoroughly.  You claim that there is.  Show us what we missed.

Anyway, suppose you read and execute "L123 = [1,2,3]".  You can, I 
presume, perform any list method on that object.  Where is it?  Some 
memory theories say 'distributed, nowhere in particular'.  Others say 
'concentrated, some particular neurons', but certainly nothing like the 
'where' of linear computer memory.  Consider another object s = 'boo'. 
Which has the lower address?

 >> without delving into the Python source itself?

Python, the abstract information algorithm language, has no 'source', 
only a specification of syntax and semantics.  The CPython source is the 
source for a particular computer machine implementation.  Any such 
implemetation has to map abstractly locationless objects to particular 
blocks of computer memory without adding extraneous, Python-accessible 
semantics, such as relative position.

>> If not, then I think you're talking about an internal implementation  
>> detail.

I think *you* are.  Giving Python objects an integer address is an 
(optional) implementation detail.  Giving them a *fixed* integer address 
is an optional CPython detail that makes certain aspects of the code 
easier but which prevents re-locating garbage collection (which I 
believe Jython does).

Anyone is free to view Python as only a linear-memory computer 
programming language (and, in some respects, as that, inferior to C). 
However, I have also viewed it as an algorithm language and, as a 
beginner (about 10 years ago), quickly dubbed it 'executable pseudocode' 
(and in that respect, much superior to C).

Terry Jan Reedy

More information about the Python-list mailing list