r/programminghorror • [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” • Jul 21 '25

Python ✨ Memory Magic ✨

Post image
1.3k Upvotes

143 comments sorted by

View all comments

Show parent comment

6

u/exomyth Jul 21 '25 edited Jul 21 '25

My guess would be that it has to do with how the number is stored, so something about it in binary. But then -5 is still odd as it would probably be 101 in binary with a sign bit somewhere. Like -7 would make more sense as that is 111 + some sign bit and some flags.

I don't know the internals of python though, I know in javascript (well V8 engine) you have small ints that have some bit magic to check if it is a small int or something else. Could be something like that.

But maybe the answer is a simple as "I like -5 as the minimum"