On Tue, 4 Jan 2005 12:18:15 -0800, Guido van Rossum email@example.com wrote:
Actually, unbound builtin methods are a different type than bound builtin methods:
Of course, but conceptually they are similar. You would still encounter the concept if you got an unbound builtin method.
Well, these are all just implementation details. They really are all just callables.
This would make pickling (or any serialization mechanism) of `Class.method' based on name next to impossible. Right now, with the appropriate support, this works:
>>> import pickle >>> class Foo: ... def bar(self): pass ... >>> pickle.loads(pickle.dumps(Foo.bar)) <unbound method Foo.bar> >>>
I don't see how it could if Foo.bar were just a function object.
Is this a purely theoretical objection or are you actually aware of anyone doing this? Anyway, that approach is pretty limited -- how would you do it for static and class methods, or methods wrapped by other decorators?
It's not a feature I often depend on, however I have made use of it on occassion. Twisted's supports serializing unbound methods this way, primarily to enhance the useability of tap files (a feature whereby an application is configured by constructing a Python object graph and then pickled to a file to later be loaded and run).
"Objection" may be too strong a word for my stance here, I just wanted to point out another potentially incompatible behavior change. I can't think of any software which I cam currently developing or maintaining which benefits from this feature, it just seems unfortunate to further complicate the already unpleasant business of serialization.