[pypy-dev] x is y <=> id(x)==id(y)

Ilya Osadchiy osadchiy.ilya at gmail.com
Sun May 5 22:11:45 CEST 2013

On Sun, May 5, 2013 at 12:59 PM, Armin Rigo <arigo at tunes.org> wrote:

> Can we fix it once and for all?  It's annoying because of id: if we
> want ``x is y`` for equal huge strings x and y, but still want
> ``id(x)==id(y)``, then we have to compute ``id(some_string)`` in a
> rather slow way, producing a huge number.  The same for tuples: if we
> always want ``(1, 2) is (1, 2)`` then we need to compute
> ``id(some_tuple)`` recursively, which can also lead to huge numbers.
> In fact such a definition can explode the memory: ``a = (); for i in
> range(100): a = (a, a); id(a)`` would likely need a 2**100-digits
> number.

If the "id(x)==id(y)" requirement is removed, does it mean that "x is y"
for immutable types is simply "x==y"?
So if we have ``a = (); for i in range(100): a = (a, a); b = (a, a)`` then
"a is b" will be computationally expensive?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20130505/ec48464f/attachment.html>

More information about the pypy-dev mailing list