[Python-Dev] Let's get rid of unbound methods

Guido van Rossum gvanrossum at gmail.com
Tue Jan 4 21:18:15 CET 2005


[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))
> <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?
-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-Dev mailing list

AltStyle によって変換されたページ (->オリジナル) /