> The current implementation keeps an array of integer objects for all integers between -5 and 256, when you create an int in that range you actually just get back a reference to the existing object. So it should be possible to change the value of 1. I suspect the behaviour of Python in this case is undefined. :-)
does anyone have any idea how they chose that range? it's a 262-wide block starting at -5, which seems incredibly arbitrary.
You could probably find out from the code's log. I'd guess the small positive integers are common due to e.g. iteration or len() of small collections and the like, and the very small negatives are due to things like error values.
> The current implementation keeps an array of integer objects for all integers between -5 and 256, when you create an int in that range you actually just get back a reference to the existing object. So it should be possible to change the value of 1. I suspect the behaviour of Python in this case is undefined. :-)
does anyone have any idea how they chose that range? it's a 262-wide block starting at -5, which seems incredibly arbitrary.
[1] https://docs.python.org/2/c-api/int.html