On Wed, Jun 5, 2013 at 7:47 AM, Andrews Medina <[email protected]> wrote:
> Hi,
>
> In the code below:
>
>>>> x = "a"
>>>> b = "a"
>>>> x is b
> False
>
> It is a bug or a behaviour?

Behavior.  Interning strings so different bindings point to the same
memory location is an optimization.  There is no guarantee that any
given Python implementation (or even the same implementation in
different versions) will do what you expect.  FWIW, Python 2.7 seems
to "get it right" (for certain user-defined definition of "right"):

>>> x = "a"
>>> y = "a"
>>> id(x)
135958064
>>> id(y)
135958064
>>> x is y
True

Skip
_______________________________________________
pypy-dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-dev

Reply via email to