Well it is.
That you overwrite the doesn’t mean that the object disappears.
The object is still there while it’s required.
The corresponding memory will be freed once it’s no longer pointed by an alive variable in the environment.
import ctypes
a = "hello world"
a_id = id(a)
a=141
print( ctypes.cast(a_id, ctypes.py_object).value)
print(a)

hello world
141

In fact this is sometimes a source of bugs in pytorch when people drag tensors without detaching them.