Registering LOTS of C level functions

Donn Cave donn at u.washington.edu
Thu Feb 1 12:39:05 EST 2001


Quoth "Grant Munsey" <gmunsey at adobe.com>:
| I am covering several libraries ... each of which has a couple of
| thousand calls (don't ask!).  I would really like some way to be
| able to register all of them to Python with one actual C function
| and an ID so that inside the C function I can generate the actual
| call by using a data structure that tells the actual functions
| address and what parameters it requires.

I do something like that for BeOS Python API modules, but I code
the functions separately as usual and put the argument table data
in static storage local to the function.  I have only about a
thousand functions, spread out over 30 odd modules, but I can't
see why it wouldn't work just fine at your scale.  (I didn't
use a tuple parse format, cf. PyArg_ParseTuple(), because I'm
dealing with C++ style function overloading.)  The key point is
to generate the code automatically.

| The only thing I can think of at the moment is to generate a
| bunch of re-direction procedures .... Tiny procedures that
| just get called from Python, add the ID code ... and then
| pass on to the "real" command handler.

Well, of course that would work.  There may not be a lot of
difference, one way or the other, however you do it - it would
be interesting to hear about results from trying a couple of
approaches.

	Donn Cave, donn at u.washington.edu



More information about the Python-list mailing list