why () is () and [] is [] work in other way?
Terry Reedy
tjreedy at udel.edu
Sat Apr 21 12:17:57 EDT 2012
On 4/21/2012 9:02 AM, Bernd Nawothnig wrote:
> You should better not rely on that result. I would consider it to be
> an implementation detail. I may be wrong, but would an implementation
> that results in
>
> () is () ==> False
>
> be correct or is the result True really demanded by the language
> specification?
To make sure that the result is not due to ref counting garbage
collection in the middle of the expression, one must test like so:
>>> a=()
>>> b=()
>>> a is b
True
This is explicitly an implementation detail, something that *may* be
done. I am not sure if the above has always been the case for CPython.
CPython's set of pre-built ints has been expended. I think string
interning has also changed.
--
Terry Jan Reedy
More information about the Python-list
mailing list