Eryk Sun <eryk...@gmail.com> added the comment:
Alternatively, one can cast the address to py_object and dereference its `value`. For example: >>> obj = bytearray(b'spam') >>> sys.getrefcount(obj) 2 >>> obj2 = ctypes.cast(id(obj), ctypes.py_object).value >>> obj2 is obj True >>> sys.getrefcount(obj) 3 >>> del obj2 >>> sys.getrefcount(obj) 2 ---------- nosy: +eryksun _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue46585> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com