Python Integer Hashing Quirk
Integers For ordinary integers, the hash value is simply the integer itself (unless it’s -1). class int: def __hash__(self): value = self if value == -1: value = -2 return value For long Python integers, things are a little trickier. For
A cropped programming reference explains how Python hashes ordinary integers, showing that -1 is changed to -2 because -1 has a special meaning internally. The joke is aimed at Python developers reacting to an unintuitive language implementation detail. EN: A cropped programming reference explains how Python hashes ordinary integers, showing that -1 is changed to -2 because -1 has a special meaning internally. The joke is aimed at Python developers reacting to an unintuitive language implementation detail.
- @gentoomemes / 15512 2025-01-08
- Type
- image
- Size
- 800×419 · 37.9 KiB
- Mood
- absurd, sarcastic
- Language
- en
- Added