[Python-Dev] Fighting the theoretical randomness of "is" on immutables
solipsis at pitrou.net
Mon May 6 15:26:56 CEST 2013
Le Mon, 6 May 2013 23:18:54 +1000,
Nick Coghlan <ncoghlan at gmail.com> a écrit :
> IIRC, Jython just delays calculating the object id() until it is
> called, and lives with it potentially being incredibly expensive to
> calculate. Is there some way PyPy can run with a model where "is" is
> defined in terms of values for immutable objects, with a lazily
> populated mapping from values to numeric ids if you're forced to
> define them through an explicit call to id()?
This sounds reasonable. Actually, for small ints, id() could simply be
a tagged pointer (e.g. "1 + 2 * myint.value").
> We're not going to change the language design because people don't
> understand the difference between "is" and "==" and then wrongly blame
> PyPy for breaking their code.
Well, if I'm doing:
mylist = [x]
and ``mylist is x`` returns False, then I pretty much consider the
Python implementation to be broken, not my code :-)
More information about the Python-Dev