def calledByOtherCode(val):
    o = Object(val)
pyo = ctypes.py_object(o)
ctypes.pythonapi.Py_IncRef(pyo)
clib.register_callback(o)

def callback(obj):
    print(obj.val)
pyobj = ctypes.py_object(obj)
ctypes.pythonapi.Py_DecRef(pyobj)
ctypes - references from C to python objects