[issue1515] deepcopy doesn't copy instance methods

Christian Heimes report at bugs.python.org
Thu Jan 31 15:18:38 CET 2008


Christian Heimes added the comment:

I've read your blog. You don't have to modify the Python core:

import copy
import types

def _deepcopy_method(x, memo):
    return type(x)(x.im_func, deepcopy(x.im_self, memo), x.im_class)
copy._deepcopy_dispatch[types.MethodType] = _deepcopy_method

I still wonder why you have to use deepcopy in your app.

----------
nosy: +tiran

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1515>
__________________________________


More information about the Python-bugs-list mailing list