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. CPython
caches certain small strings and returns the same object when asked
for a string with identical content to one in the cache, thus the
behavior you're observing.

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to