[Pyrex] Re: Python type syntax for Pyrex?

Thomas Heller theller at python.net
Mon Jan 10 21:35:37 CET 2005


"Phillip J. Eby" <pje at telecommunity.com> writes:

> Guido's latest type syntax proposal at
> http://www.artima.com/weblogs/viewpost.jsp?thread=87182 looks almost
> like it might be suitable for use in a future version of Pyrex in
> place of cdef+type prefixes.
[...]
> It's interesting to think about, and to wonder if ctypes and Pyrex
> could converge on a common way to "spell" C types as Python type
> expressions.  Then, one could prototype code with ctypes and then
> compile it with Pyrex, or add type expressions to regular Python code
> and compile with Pyrex to enhance performance.

Only some rants...

Pyrex and ctypes might be nearer to each other than we normally think
they are.  Some time ago I played with some pyrex libxml2 wrapper,
converting it to ctypes.  Basically all that was required was to remove
all the pyrex type declarations, and replace some typical pyrex idioms
by the ctypes ones.  For example 'if ns is NULL: ...' (pyrex test for
NULL pointers) with 'if ns: ...' (ctypes NULL pointer test), and
'self._c_node.name' (pyrex pointer deref) with 'self._c_node[0].name'
(ctypes pointer deref).


Second, I have a ctypes code generator nearly ready (whatever that
means, there are still some more or less severe problems to solve),
which uses gccxml to parse C header files.  The backend could probably
spit out pyrex code instead types wrappers as well.  I could also use
some help and/or ideas from other developers for this tool.

> Anyway, not a proposal, just food for interesting thought, and to
> speculate on whether there are any Pyrex features that can't be
> expressed with the new syntax.  That is, is there anything we should
> be proposing that Guido add?

I would have to really *read* the proposal first ;-)

Thomas




More information about the Pyrex mailing list