[Python-Dev] instancemethod_getattro seems to be partially wrong
Christian Tismer
tismer at tismer.com
Tue Nov 18 20:50:07 EST 2003
Hi Guido,
...
> 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
--
Christian Tismer :^) <mailto:tismer at tismer.com>
Mission Impossible 5oftware : Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9a : *Starship* http://starship.python.net/
14109 Berlin : PGP key -> http://wwwkeys.pgp.net/
work +49 30 89 09 53 34 home +49 30 802 86 56 mobile +49 173 24 18 776
PGP 0x57F3BF04 9064 F4E1 D754 C2FF 1619 305B C09C 5A3B 57F3 BF04
whom do you want to sponsor today? http://www.stackless.com/
More information about the Python-Dev
mailing list