Python code -> to C code

Thomas Heller theller at python.net
Wed Apr 30 05:27:41 EDT 2003


Duncan Booth <duncan at NOSPAMrcp.co.uk> writes:

> claird at lairds.com (Cameron Laird) wrote in
> news:vatlfeb16jlled at corp.supernews.com: 
> 
> > In article <Xns936C8AB67B739duncanrcpcouk at 127.0.0.1>,
> > Duncan Booth  <duncan at rcp.co.uk> wrote:
> >                .
> >                .
> >                .
> >>The easiest solution is to leave the program in Python and just call
> >>the relevant functions from C. Possibly the easiest way to do this
> >>would be to use Pyrex.
> >                .
> >           [persuasive illustration]
> >                .
> >                .
> > ctypes <URL: http://starship.python.net/crew/theller/ctypes.html >
> > should be even easier to use.
> 
> Does ctypes support embedding? If so, it isn't obvious from that webpage.

ctypes allows to create C functions from Python callables, and pass the
pointers to them to C apis.

Normally this is used to implement "callback functions" in Python, to
call functions like Windows' EnumWindows(), or to implement COM object
method tables.

Does this count as embedding? It seems so, although I have never seen it
this way.

Thomas




More information about the Python-list mailing list