I need to create a bunch of partial
functions that can be pickled. Empirically testing this, it seems to work fine:
import pickle
import functools
pickle.dumps(functools.partial(int, base=2))
# b'\x80\x03cfunctools\npartial\nq\x00cbuiltins\nint\nq\x01\x85q\x02Rq\x03(h\x01)}q\x04X\x04\x00\x00\x00baseq\x05K\x02sNtq\x06b.'
However, this is not stated explicitly in the documentation, and the given "roughly equivalent" function of functools.partial()
is not picklable.
Can I assume that partial
objects are picklable in any circumstances (no edge cases, independently of the C / Python implementation)?