[pypy-issue] [issue1177] The empty string is a new object every time

Armin Rigo tracker at bugs.pypy.org
Thu Jun 14 10:55:55 CEST 2012

Armin Rigo <armin.rigo at gmail.com> added the comment:

Note that we already had to go through hoops to make "x is 0" work as it does in
CPython.  Strings and unicodes are the last missing pieces of that puzzle, I
suppose.  We could hack and pretend that all empty strings are identical, like
we do with all equal integers, floats, complexes and longs.  Of course, if we
do, then someone will post a bug report about single-character strings too (but
not single-character unicodes, because that doesn't work on CPython either).

Note that any performance characteristics with the JIT at this level is rather
nonsensical, because it depends on the context.  Indeed, a priori, we can think
that it is often *faster* to compare 'x == 0' than 'x is 0', because the latter
requires allocating the box for 'x' whereas the former not.  (This is not true
due to more advanced optimizations nowadays; the performance is the same.)

nosy: +arigo

PyPy bug tracker <tracker at bugs.pypy.org>

More information about the pypy-issue mailing list