2 ms·
FWIW, this segfaults CPython in 2 lines: import ctypes ctypes.cast(1, ctypes.py_object) Interestingly, this works: import ctypes, gc x = 22 _id = i
by westurner 7y ago
FWIW, this segfaults CPython in 2 lines:
import ctypes
ctypes.cast(1, ctypes.py_object)
Interestingly, this works:
import ctypes, gc
x = 22
_id = id(x)
del x
gc.collect()
y = ctypes.cast(_id, ctypes.py_object).value
assert y == 22