[issue9276] pickle should support methods

Raymond Hettinger report at bugs.python.org
Tue Mar 1 20:39:58 CET 2011


Raymond Hettinger <rhettinger at users.sourceforge.net> added the comment:

> how about we give every function a `.__parent_class__` 
> attribute saying which class it is a method of? 

Won't work.  The same function can be used in multiple classes.

The function object is independent of the class.  This is conceptually no different that the unremarkable fact that any object can be stored in multiple dictionaries and the object is not responsible for knowing which dictionaries it is stored in.

def f(self): ...   # not even defined inside a class
A.f = f            # stored in class A
B.f = f            # also stored in class B
dir(f)             # f doesn't know where it is stored

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9276>
_______________________________________


More information about the Python-bugs-list mailing list