[Python-Dev] Let's get rid of unbound methods (original) (raw)
Jp Calderone exarkun at divmod.com
Tue Jan 4 21:27:37 CET 2005
- Previous message: [Python-Dev] Let's get rid of unbound methods
- Next message: [Python-Dev] Let's get rid of unbound methods
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Tue, 4 Jan 2005 12🔞15 -0800, Guido van Rossum <gvanrossum at gmail.com> wrote:
[me] > > Actually, unbound builtin methods are a different type than bound > > builtin methods:
[Jim] > 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. [Jp] > 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)) > > >>> > > 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.
Jp
- Previous message: [Python-Dev] Let's get rid of unbound methods
- Next message: [Python-Dev] Let's get rid of unbound methods
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]