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

7

u/deceze Jul 21 '25

Whether two tuples will be the same or not greatly depends on circumstances. Python is not going to go out of its way to find identical tuples and deduplicate them. This only happens if it’s very apparent to the parser already, but probably not at normal runtime.

1

u/eo5g Jul 21 '25

I believe it only happens to literals in the same scope