The concept of immortal objects was introduced since PEP 683. I saw many internal objects (such as small ints, None, strings, etc.) have been made immortal, but I wonder if it is possible to make a user-defined object immortal in the current Python versions? If not, what could be a workaround?
For example,
class MyClass:
def __init__(self, x):
self._x = x
mycls = MyClass(3)
# Does there exist or would there be some public API to make `mycls` immortal?
sys.setimmortal(mycls) # for example