Efficient data flow between orthogonal C extensions?

Magnus Lie Hetland mlh at furu.idi.ntnu.no
Thu Jun 5 07:55:01 EDT 2003


In article <87el29rpmv.fsf at smtp.gsi.de>, Pierre Schnizer wrote:
>mlh at furu.idi.ntnu.no (Magnus Lie Hetland) writes:
>
[snip]
>If you are using callbacks,

That was, at least, my original idea, although a more centralized
version would also be possible.

>you can wrap the callbacks with swig.

Sounds good....

>While swig will not generate helpers to call python functions from C,
>you can pass pointers to C functions.
>http://www.swig.org/Doc1.3/SWIG.html#n30

Hm. I don't quite get this... This piece of documentation does seem to
work with Python-implemented callbacks... And the name-based approach
strikes me as a bit impractical. A callback has to have a given name
to be applicable -- or am I misunderstanding? Even though this doesn't
mean that the extensions need to know about each other, conceptually,
the would need to know what the methods of the other extensions are
called...

It would be nice to be able to supply the extension with an arbitrary
object (e.g. a PyCObject) and have it cast it and use it itself. Of
course, assigning a function to a variable with the correct name (if
that would work) isn't too much of a nuisance.

Any input on this? Am I misunderstanding the functionality? And... I
suppose the declared callbacks would be in the namespace of the
extension module? (Otherwise, how would it be imported?) In that case,
wouldn't it be necessary to assign a function pointer to it anyway?
Hm...

I guess I'll have to look into whether this is the way to go (and
perhaps actually try it before speculating too much ;). Thanks for the
input.

>Pierre

-- 
Magnus Lie Hetland                "In this house we obey the laws of
http://hetland.org                 thermodynamics!"    Homer Simpson




More information about the Python-list mailing list