Why does Python do this?

You just happened to find the breaking point if the pythons memory management for integers, I was hoping you would have known it ahead of time and were being decidedly clever

In Python, the is operator checks for object identity. It’s explicitly asking if the two variable names are currently assigned to the exact same object in memory.

The == operator, however, is for value equality. Instead of checking to see if you’re pointing to the same object in memory, it’s asking if those objects’ values are the same.

Additionally, all numbers from -5 to 256 inclusive are singletons in Python: there is one and only one instance of any of them in the Python runtime.

There are times when you definitely want to know you’re not operating on the same object: for example, you’ve got two objects that should control different network connections. However, someone may have made an assignment that shouldn’t have been made. You can sort out whether it’s safe to call methods on both by using the identity operator (is).