copy modules of the standard library make use of a class’s
__reduce__() method for customizing the pickle/copy process. They seem to have a consistent view of the first 5 elements of the returned tuple:
(func, args, state, listiter, dictiter) but the 6th element seems different. For
state_setter, a callable with signature
state_setter(obj, state)->None, but for
deepcopy with signature
deepcopy(arg: T, memo) -> T.
What’s the recommended way to write the callable for the 6th element of the return tuple of
__reduce__() so that it can work with both pickle and copy?