On 07/08/2011 04:14 PM, Amaury Forgeot d'Arc 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.
I think in the end id is the hard problem. Object identity can be fixed.
We could say that "a is b" uses equality for primitive objects.
However, then id needs to be fixed too, so that the following property
holds:
"a is b" if and only if "id(a) == id(b)"
This is the harder part.
Carl Friedrich
_______________________________________________
pypy-dev mailing list
pypy-dev@python.org
http://mail.python.org/mailman/listinfo/pypy-dev