def _pickleFunction(f):
"""
Reduce, in the sense of L{pickle}'s C{object.__reduce__} special method, a
function object into its constituent parts.
@param f: The function to reduce.
@type f: L{types.FunctionType}
@return: a 2-tuple of a reference to L{_unpickleFunction} and a tuple of
its arguments, a 1-tuple of the function's fully qualified name.
@rtype: 2-tuple of C{callable, native string}
"""
if f.__name__ == '<lambda>':
raise _UniversalPicklingError(
"Cannot pickle lambda function: {}".format(f))
return (_unpickleFunction,
tuple([".".join([f.__module__, f.__qualname__])]))
评论列表
文章目录