Re: '11' + '1' is '111'?

2009-10-30 Thread Ben Finney
metal metal...@gmail.com writes: '11' + '1' == '111' is well known. but it suprises me '11'+'1' IS '111'. Don't be surprised. Rather, don't depend on implementation-dependent behaviour, such as whether two objects that compare equal will or will not have the same identity. That behaviour

'11' + '1' is '111'?

2009-10-29 Thread metal
'11' + '1' == '111' is well known. but it suprises me '11'+'1' IS '111'. Why? Obviously they are two differnt object. Is this special feature of imutable object? -- http://mail.python.org/mailman/listinfo/python-list

Re: '11' + '1' is '111'?

2009-10-29 Thread Chris Rebert
On Thu, Oct 29, 2009 at 5:43 PM, metal metal...@gmail.com wrote: '11' + '1' == '111' is well known. but it suprises me '11'+'1' IS '111'. Why? Obviously they are two differnt object. Is this special feature of imutable object? It's an implementation detail used to optimize performance

Re: '11' + '1' is '111'?

2009-10-29 Thread Benjamin Kaplan
On Thu, Oct 29, 2009 at 8:43 PM, metal metal...@gmail.com wrote: '11' + '1' == '111' is well known. but it suprises me '11'+'1' IS '111'. Why? Obviously they are two differnt object. Is this special feature of imutable object? It's an implementation detail of small strings without spaces

Re: '11' + '1' is '111'?

2009-10-29 Thread metal
On 10月30日, 上午8时49分, Chris Rebert c...@rebertia.com wrote: On Thu, Oct 29, 2009 at 5:43 PM, metal metal...@gmail.com wrote: '11' + '1' == '111' is well known. but it suprises me '11'+'1' IS '111'. Why? Obviously they are two differnt object. Is this special feature of imutable object

Re: '11' + '1' is '111'?

2009-10-29 Thread Benjamin Peterson
metal metal29a at gmail.com writes: '11' + '1' == '111' is well known. but it suprises me '11'+'1' IS '111'. Why? Obviously they are two differnt object. Is this special feature of imutable object? As other posters have pointed out, CPython does cache some small strings. In this case

Re: '11' + '1' is '111'?

2009-10-29 Thread John Machin
On Oct 30, 11:52 am, Benjamin Kaplan benjamin.kap...@case.edu wrote: On Thu, Oct 29, 2009 at 8:43 PM, metal metal...@gmail.com wrote: '11' + '1' == '111' is well known. but it suprises me '11'+'1' IS '111'. Why? Obviously they are two differnt object. Is this special feature

Re: '11' + '1' is '111'?

2009-10-29 Thread metal
On 10月30日, 上午9时03分, Benjamin Peterson benja...@python.org wrote: metal metal29a at gmail.com writes: '11' + '1' == '111' is well known. but it suprises me '11'+'1' IS '111'. Why? Obviously they are two differnt object. Is this special feature of imutable object? As other posters

Re: '11' + '1' is '111'?

2009-10-29 Thread MRAB
Benjamin Peterson wrote: metal metal29a at gmail.com writes: '11' + '1' == '111' is well known. but it suprises me '11'+'1' IS '111'. Why? Obviously they are two differnt object. Is this special feature of imutable object? As other posters have pointed out, CPython does cache some small