See also
This excellent discovery was not my own! The original author (Kate Murphy)‘s writeup is here: https://kate.io/blog/2017/08/22/weird-python-integers/
tl;dr:
import ctypes
def mutate_int(an_int, new_value):
ctypes.memmove(id(an_int) + 24, id(new_value) + 24, 8)
mutate_int(4, 7)
# 4 is now 7.