why () is () and [] is [] work in other way?

Steven D'Aprano steve+comp.lang.python at pearwood.info
Thu Apr 26 04:40:33 EDT 2012


On Wed, 25 Apr 2012 22:48:33 -0700, John Nagle wrote:

> On 4/25/2012 5:01 PM, Steven D'Aprano wrote:
>> On Wed, 25 Apr 2012 13:49:24 -0700, Adam Skutt wrote:
>>
>>> Though, maybe it's better to use a different keyword than 'is' though,
>>> due to the plain English
>>> connotations of the term; I like 'sameobj' personally, for whatever
>>> little it matters.  Really, I think taking away the 'is' operator
>>> altogether is better, so the only way to test identity is:
>>>      id(x) == id(y)
>>
>> Four reasons why that's a bad idea:
>>
>> 1) The "is" operator is fast, because it can be implemented directly by
>> the interpreter as a simple pointer comparison (or equivalent).
> 
>     This assumes that everything is, internally, an object.

No it doesn't. It assumes that everything provides the external interface 
of an object. Internally, the implementation could be anything you like, 
so long as it simulates an object when observed from Python.


-- 
Steven



More information about the Python-list mailing list