Register / Login
Python Caches Integer object in some range
posted 3 years ago
In a book 'Core Python Programming' I read that Python caches simple integer objects between a range(-1, 100) which may change..
But this is not same for the float..
So there was an exammple like this: -
a = 1 b = 1 id(a) == id(b) prints True c = 1.0 d = 1.0 id(c) == id(d) prints False
But when I ran this code in my Python interpreter, I got
value for both of them...
So, this mean my Python is caching both Integer and Float objects..
How is this happening??
Is this because of Version Difference?? I'm using Python 2.7..
Boxing, ==, and Equals()
Precision of float and double
Q on Integer()
casting - from Dan's mock casting1