[Python-porting] Pickling unbound methods on Python 3

cool-RR cool-rr at cool-rr.com
Sat May 29 18:40:14 CEST 2010


On Sat, May 29, 2010 at 5:46 PM, R. David Murray <rdmurray at bitdance.com>wrote:

> On Fri, 28 May 2010 21:55:28 +0200, cool-RR wrote:
> > One person told me that given an unbound method in Python 3.x, it's
> > *impossible* to tell to which class it belongs. Is it true?
>
> I believe that that is true.  In Python3 there is no such thing as an
> unbound method as a distinct object type.  There are functions, and
> there are bound methods.  See the second sentence in this section:
>
>
> http://docs.python.org/release/3.0.1/whatsnew/3.0.html#operators-and-special-methods


I see. Where would be a good place to discuss this decision? I would want
3.2 to allow pickling of unbound methods.



> You'll probably have to explain more about the problem you are
> trying to solve in order for us to help you find a solution.
>
> --
> R. David Murray                                      www.bitdance.com
>

I found a hacky workaround: When I have a method `my_method` that I want to
pickle, I write `my_method = my_class.my_method` in the method's module.

So no need to burden this list with the specifics of my problem.

Now I only worry about the future: I want 3.2 to enable pickling of unbound
methods so I could get rid of this workaround in the future.

Ram.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-porting/attachments/20100529/348e2b62/attachment.html>


More information about the Python-porting mailing list