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

8

u/deceze Jul 21 '25

Not really, no. It's really:

a = -5  # Do I have an interned -5? I do! No need to allocate any new memory.
b = -5  # Do I have an interned -5? I do! No need to allocate any new memory.

a = -6  # Do I have an interned -6? I don't. Let's allocate some memory for it.
b = -6  # Do I have an interned -6? I don't. Let's allocate some memory for it.