Um, my brain just did a double-take. Standard Python doesn't let you do that, so you must be changing some internals. Which parts of Python are you trying to change and which parts are you trying to keep unchanged? If you were using a different metaclass you could just create a different implementation of instancemethod that does what you want, so apparently you're not going that route. (With new-style classes, instancemethod isn't that special any more -- it's just a currying construct with some extra baggage.)
No no no, I'm not fiddling around with any internals, here. I just want to use the machinary as it is, and to be able to pickle almost everything.
So, if somebody did a v=C().x, I have that variable around. In order to pickle it, I ask for its __reduce__, or in other words, I don't ask for it, I try to supply it, so the pickling engine can find it. My expectation is that C().x.__reduce__ gives me the bound __reduce__ method of the bound x method of a C instance.
Try again. I don't think that C().f.__reduce__ should be a method of an instance of C. You want it to be a method of a bound method object, right?
No, __reduce__ is a method of f, which is bound to an instance of C. Calling it will give me what I need to pickle the bound f method. This is all what I want. I think this is just natural.
If that's not the way to do it, which is it?
I think what I suggested above -- forget about the existing instancemethod implementation. But I really don't understand the context in which you are doing this well enough to give you advice, and in any context that I understand the whole construct doesn't make sense. :-(
Once again. What I try to achieve is complete thread pickling. That means, I need to supply pickling methods to all objects which don't have builtin support in cPickle or which don't provide __reduce__ already. I have done this for some 10 or more types, successfully. Bound PyCFunction objects are nice and don't give me a problem. Bound PyFunction objects do give me a problem, since they don't want to give me what they are bound to.
My options are: - Do an ugly patch that special cases for __reduce__, which I did just now, in order to seet hings working. - get the master's voice about how to do this generally right, and do it generally right.
I would of course prefer the latter, but I also try to save as much time as I can while supporting my clients, since Stackless is almost no longer sponsored, and I have money problems.
thanks so much -- chris