[Pyrex] Pyrex versus ctypes, again

Andreas Kostyrka andreas at kostyrka.org
Mon Aug 1 10:46:58 CEST 2005


Am Freitag, den 22.07.2005, 21:58 +0200 schrieb Peter Brinkmann:
> 
> Greg,
> Thanks for your prompt reply! I guess I'll stick to ctypes for this
> particular project, then, but I'll keep Pyrex in mind for the future.

One thing to consider is, because you've mentioned huge data structures:
ctypes is by design (because the access layer gets interpreted in
Python) is slower.

Pyrex OTOH, while not providing an "automatic" access (a la Swig, or
other wrapper generators), allows you to create a "safe" python
interface that can manipulate the data structures and APIs at C-speed.

For example, copying a string buffer from Python to C has the penality
of a byte-to-byte assignment in C, not the costs of one or multiple
Python function calls.

Andreas

> Best,
>     Peter
> 
> 
> On Sat, Jul 23, 2005 at 12:08:26AM +1200, Greg Ewing wrote:
> > 
> > Peter Brinkmann wrote:
> > 
> > >Now, my main concern
> > >is that I don't see how to use pyrex to expose C structs and unions to
> > >Python. They may appear in pyrex code, but they won't be available on
> > >the Python side, right?
> > 
> > Not automatically, no. Pyrex provides what you need
> > to build a Pythonic interface to them, but you have
> > to do the building yourself.
> > 
> > If you want something you can just throw a bunch
> > of C declarations at and get a Python interface
> > for free, Pyrex isn't for you.
> > 
> > Greg
> > 
> > 
> > _______________________________________________
> > Pyrex mailing list
> > Pyrex at lists.copyleft.no
> > http://lists.copyleft.no/mailman/listinfo/pyrex
> > 
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
Url : http://lists.copyleft.no/pipermail/pyrex/attachments/20050801/b7584027/attachment.bin


More information about the Pyrex mailing list