Today I learned that the values float("inf") and float("-inf") have two very special hashes:
>>> hash(float("inf"))
314159
>>> hash(float("-inf"))
-314159
In case you can't tell, those are the first few digits of the mathematical constant \(\pi\):
>>> import math
>>> math.pi
3.141592653589793
## ^^^^^
I learned about this during the CPython panel held at EuroPython 2025, after the hosts ลukasz & Pablo asked the panel if they know what the hash of -1 was.
Get ready for 12 intense days of problem-solving. The โAlgorithm Mastery Bootcampโ starts December 1st and it will feature 24 programming challenges, live analysis sessions, a supportive community of like-minded problem-solvers, and more! Join now and become the Python expert others can rely on.