Ishwor wrote:

hi all,
 can anyone tell me why this distinction? i mean why it returns False
on floats??

a = 1
b = 1
a is b

True

a = 1.1
b = 1.1
a is b

False


thanx .

There is no guarantee that this will hold in all implementations of Python.

The majority implementation, usually called CPython because its implementation language is C, keeps copies of the first 100 (?) integers so it doesn't have to create separate integer objects each time they are required.

No caching at all is applied to floats, as far as I can tell.

>>> a = 250
>>> b = 250
>>> a is b
False

regards
 Steve

--
http://www.holdenweb.com
http://pydish.holdenweb.com
Holden Web LLC +1 800 494 3119
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to