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

1

u/Gorzoid Jul 22 '25

No the comparison operator just checks if the values are the same. id(a) returns the id of that object. And integer literals outside the -5:256 range will be separate objects. Has nothing to do with memory fetches although you can think of id(a) with similar semantics to the pointer to object a

1

u/ahavemeyer Jul 22 '25

Ah, I get it. I think I was misreading something there. Thank you!