Steven D'Aprano steve+comp.lang.python at
Wed Mar 5 19:29:18 CET 2014

On Tue, 04 Mar 2014 22:03:36 -0800, Rustom Mody wrote:

> On Wednesday, March 5, 2014 10:36:37 AM UTC+5:30, Steven D'Aprano wrote:
>> On Tue, 04 Mar 2014 19:36:38 -0800, Rustom Mody wrote:
>> > Python's 'is' leaks
>> > the machine abstraction. 'id' does it legitimately (somewhat), 'is'
>> > does it illegitimately
>> Can you elaborate on why id() is legitimate and "is" is not?
> Mostly a question of more or less infelicitous English leading to
> philosophical nonsense. [And note I put a 'somewhat']

Well it is certainly true that this discussion has lead to philosophical 
nonsense from one of us.

> I can say "'id' is just 'machine-id' is just address at some low level"

You can say it, but you would be wrong.

I don't know how many times you have to be told. The id() function in 
Python is not defined as returning the address of the object. There is no 
guarantee that objects even have a consistent, stable addresses. Some 
garbage collectors will move objects around. The Python language does not 
claim that the id() function will return the address of objects, it says 
that it will return an abstract ID number that is unique for that object 
while the object exists.

> Its uglier to say "Is is machine-is"
> And before you bring it up, "Jython's id is not machine-id" is putting
> the cart before the horse.
> "Jython is an imitation of Cpython

That's wrong. Jython is not an imitation, it is an independent 
implementation of the same language. Since both CPython and Jython follow 
the specification of the language, both are legitimate Python compilers. 

Both the Jython and CPython id() functions are compliant with the 
language definition. The Jython id() function is better, because it 
doesn't encourage people to mistakenly and foolishly imagine that id() 
equals address.

Steven D'Aprano

More information about the Python-list mailing list