append on lists

Terry Reedy tjreedy at udel.edu
Tue Sep 16 13:31:40 EDT 2008


Maric Michaud wrote:
> Le Tuesday 16 September 2008 15:57:53 Grant Edwards, vous avez écrit :
>> On 2008-09-16, Maric Michaud <maric at aristote.info> wrote:
>>> all expressions that return something, return a new object,
>> That's not _quite_ true:
>>>>> a=1
>>>>> b=a.__add__(0)
>>>>> a is b
>> True
>>
>> ;)
> 
> This is implementation specific, the specification of the language says that 
> it should be false,

Please quote the section of the manual that says this.

 > and it is for higher numbers :

Agaiin, this is implementation specific.  An implementation would be 
free to special-case any or all of +a, a+0, a-0, a*1, a//1, a**1, a<<0, 
a>>0, and a|0 and return a.  That CPython only optimizes the first is a 
judgment that the other cases are too rare to bother with.

  > Don't disturb our OP, with side questions, please, it was enough 
hard like
> this ;)

Stop peddling false information.  For immutable objects, identity is 
irrelevant except for id and is.

tjr





More information about the Python-list mailing list