accessing method name from within a c-function
jan at muskelfisch.com
Fri Jan 18 07:37:38 EST 2002
> So the complete scaffolding for this is in C?
Yep, in c++ to be precise. But thanks to you, I now realize that this
is actually the problem :)
> For your situation, I would expose the single C entry point and construct
> callable wrappers in Python for each name. Then the name becomes an
> additional argument to the call. This is much easier than trying to scrabble
> up the Python stack (through one of those popular exception hacks) for a
> stack frame holding the name being called. It will also be less costly.
Yeah - that's it! I just wasn't thinking pythonesque. So each time,
the client registers a custom native c method, I let the interpreter
evaluate a function definition of a wrapper function. This wrapper,
when invoked by python code, calls my c-entry-point-function and
passes it's name right before 'self'. I like that, this way my code
doesn't depend on the interpreter's implementation details.
Thank you very much for your help.
More information about the Python-list