>>> import copy
>>> copy.deepcopy(max)
Traceback (most recent call last):
File "<pyshell#2>", line 1, in ?
copy.deepcopy(max)
File "C:\PYTHON23\lib\copy.py", line 205, in deepcopy
y = _reconstruct(x, rv, 1, memo)
File "C:\PYTHON23\lib\copy.py", line 336, in _reconstruct
y = callable(*args)
File "C:\PYTHON23\Lib\copy_reg.py", line 84, in __newobj__
return cls.__new__(cls, *args)
TypeError: object.__new__(builtin_function_or_method) is not
safe, use builtin_function_or_method.__new__()
Steven Taschuk's guess is that all things pickleable should be
copyable since copy uses the same protocol as pickle. (He is
not sure though) He demonstrates this idea with the following
example:
>>> import pickle
>>> pickle.loads(pickle.dumps(max))
<built-in function max>
which succeeds unlike the first example.
|