Calling C Function Pointers from Python

Thomas Wouters thomas at xs4all.net
Sun Jul 30 11:32:10 EDT 2000


On Sun, Jul 30, 2000 at 12:19:23PM +0000, Erwin S. Andreasen wrote:

> >   calldll is a low level Python extension libary which contains functions
> >for creating buffers, loading DLLs, finding the address of functions within
> >the loaded DLLs, and calling the functions. On top of that is a higher level
> >windll module that makes it more convenient to call.

> Interesting -- it should be possible to create a similar module for loading
> shared objects under UNIX and calling functions in those. Although it wouldn't
> be that easy, since you would need to find a way to call a function pointer
> with a variable number of arguments in C.

Look at the 'dl' module in the standard Python distribution. It's not
terribly useful, though, for the reasons Neil pointed out: it's easy to
abuse, it's easy to mis-use, and as such, most people do not enable it. (I
don't, for instance ;) You're usually better off SWIGing the library you
wish to interface with.

-- 
Thomas Wouters <thomas at xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!




More information about the Python-list mailing list