len(var) is [CONSTANT] equal to len(var) == [CONSTANT]?

Fredrik Lundh fredrik at pythonware.com
Thu Nov 23 05:57:13 EST 2006


Tor Erik Soenvisen wrote:

> (len(['']) is 1) == (len(['']) == 1) => True
> 
> Is this the case for all numbers?

I'm not sure what you're asking here, but if you digest the following 
facts, maybe you can answer it yourself:

1) all objects that exist at the same time have distinct identifies, and 
2) a Python implementation may or may not hand reuse existing immutable 
objects that have the same value when asked to create a new object,
3) identities are recycled when objects are deleted, and
4) [] and {} always create a new object every time they're evaluated.

</F>




More information about the Python-list mailing list