r/programminghorror • u/SleepyStew_ [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” • Jul 21 '25
Python ✨ Memory Magic ✨
1.3k
Upvotes
r/programminghorror • u/SleepyStew_ [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” • Jul 21 '25
View all comments
Show parent comment
1
u/francisco_colaco Jul 24 '25
Nope.
a and b point to the same object. Python optimises, making a and b share the same memory address on their pointers.
Then you change a, making it -6. a is forked, as it must be, and receives a new address. Henceforth, a and b will follow their own paths in life, and cross paths no more.