[Python-Dev] Need advice, maybe support

Christian Tismer tismer@tismer.com
Tue, 20 May 2003 00:09:14 +0200


Lieber Martin,

> Christian Tismer <tismer@tismer.com> writes:
> 
> 
>>The problem is that I need to give extra semantics to existing
>>objects, which are PyCFunction objects.  I think putting an extra
>>bit into the type object doesn't help, unless I use a new type. But
>>then I don't need the flag.  An old extension module which is loaded
>>into my Python will always use my PyCFunction, since this is always
>>borrowed.
> 
> 
> I understand the concern is not about changing PyCFunction, but about
> changing PyMethodDef, which would get another field.

Exactly. This is the static structure which is lingering around in
many old extension modules, and to change it would require massive
recompilation.

> I think you can avoid adding a field to PyMethodDef, by providing a
> PyMethodDefEx structure, which has the extra field, and is referred-to
> from (a new slot in) the type object. The slots in the type object
> that refer to PyMethodDefs would either get set to NULL, or
> initialized with a copy of the PyMethodDefEx with the extra field
> removed.

Hey, that's really not bad!

Today, I've banged my head on my desk many times, trying to
find out how to turn a clean, new approach into the least
hackish surrogate, which is binary compatible.
Well, I found some, not really pretty but working.
It uses not an extra field, but extra records, which are
used as sibling fields, past the end of the method table.

I have to think about what implementation is more efficient,
and uses less of my resources. Since Guido donated 8+1 bits
to me, I have a big degree of freedom about how I will
implement things in the future.

Maybe I'd go ahead and see these bits checked in ASAP, and then
re-think the design. Perhaps I will give back 8 bits, when I really
don't need them, but I really don't know, yet.

thanks anyway -- good idea - chris

-- 
Christian Tismer             :^)   <mailto:tismer@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  pager +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/