I need to dump and load my object which includes objects from third party modules over which I have no control. These objects contain ctypes pointers that dill (pickle) cannot save:
ValueError: ctypes objects containing pointers cannot be pickled
It would be quite enough for me if after dump/load I get everything that can be saved except pointers.
Minimal reproducible example:
import dill
import ctypes
from dataclasses import dataclass
@dataclass
class Test:
s:str
p:ctypes.pointer
t = Test(s='str', p=ctypes.pointer( ctypes.c_int(1)) )
print(t)
# Test(s='str', p=<ctypes.wintypes.LP_c_long object at 0x05DD6D00>)
# an exception will be raised here:
ds = dill.dumps(t)
# what i want:
t2 = dill.loads(ds)
print(t2)
# Test(s='str')