On Fri, Jul 8, 2011 at 4:14 PM, Amaury Forgeot d'Arc <amaur...@gmail.com> wrote: > 2011/7/8 Cesare Di Mauro <cesare.di.ma...@gmail.com>: >> I fully agree. It's not an issue, but an implementation-specific detail >> which programmers don't have to assume always true. >> >> CPython can be compiled without "smallints" (-5..256, if I remember >> correctly) caching. There's a #DEFINE that can be disabled, so EVERY int (or >> long) will be allocated, so using the is operator will return False most of >> the time (unless you are just copied exactly the same object). >> >> The same applies for 1 character strings, which are USUALLY cached by >> CPython. > > But the problem here is not object cache, but preservation of object identity, > which is quite different. > Python containers are supposed to keep the objects you put inside:
[citation needed] array.array does not for one > > myList.append(x) > assert myList(-1) is x > > myDict[x] = 1 > for key in myDict: > if key is x: > ... > also dict doesn't work if you overwrite the key: d = {1003: None} x = 1003 d[x] = None d.keys()[0] is x _______________________________________________ pypy-dev mailing list pypy-dev@python.org http://mail.python.org/mailman/listinfo/pypy-dev