ANN: Pyrex - a language for writing Python extension modules

Greg Ewing greg at cosc.canterbury.ac.nz
Tue Apr 9 22:29:02 EDT 2002


Skip Montanaro <skip at pobox.com>:

> Interesting, but why not simply attach the type information to function
> attributes so the Pyrex code really is just Python?

I imagine that would look extremely ugly. Also, functions aren't the
only places that type information, and other kinds of information, is
needed in Pyrex. Have you read the Language Overview? There's much,
much more to Pyrex than just annotating things with types.

>    You can defer Pyrex compilation until you realize you need it.  Naively
>    compiling all your code to C makes for a lot of (object) code bloat and
>    doesn't necessarily speed anything up (if, for example, the code is I/O
>    bound or not executed frequently enough).  This was one of the problems
>    with Python2C.

You're not meant to compile all your Python code with Pyrex.
You only put Python code in a Pyrex module if it's needed to
interface with non-Python code. Pyrex isn't designed to speed
up Python code, but to bridge the gap between Python and
non-Python. Speed, if any, comes from the non-Python code
(Pyrex code operating on C data, or external C code).

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg at cosc.canterbury.ac.nz	   +--------------------------------------+





More information about the Python-list mailing list