Brief DescriptionPyrex lets you write code that mixes Python and C data types any way you want, and compiles it into a C extension for Python.
Contributed by Users
Quick Guide to Pyrex
Contributed by Michael JasonSmith.
If the above link doesn't work, there is a copy here.
Using Pyrex to write stand-alone programs that embed a Python interpreter.
Contributed by David McNab.
C++ Wrapping Tutorial
Contributed by David McNab. Warning: This page is really for Cython and mentions some Cython features that Pyrex doesn't have. Some of what it says is also obsoleted by recently-added C++ features in Pyrex.
Pyrex-0.9.9.tar.gz (255272 bytes, 2010-04-12)
Version 0.9.9Some features for interfacing with C++ code have been introduced, a few things have been changed, and some bugs have been fixed. See the Release Notes and CHANGES for details.
PatchesWARNING: I have not reviewed or tested these patches - use them at your own risk.
Sam Rushing has submitted a patch to Pyrex 0.9.3.1 which adds some conditional compilation facilities.
Lenard Lindstrom contributed some patches to Pyrex 0.9.3.1 to improve the C++ compatibility of the generated code. Since 0.9.4 these should no longer be necessary.
PackagesThese packages are maintained by others, so they may not be up to date with the latest version.
Contributed by Giovanni Bajo
Fedora Core 1
Fedora Core 2
Contributed by Jan Ondrej
Contributed by Samuel Thibault
Pyrex Builder X
A mini-IDE for building Pyrex projects on MacOSX, by Nik Molnar.
You are invited to subscribe to the Pyrex Mailing List for all Pyrex-related discussions.
Thanks are due to Johannes Grødem of Copyleft Software for setting up and hosting this list at the request of Joakim Ziegler.
Discussion of Pyrex is also welcome on the Python newsgroup, comp.lang.python.
I don't normally use IRC myself, but you may find someone there who's able to help you.
Greg Ewing (firstname.lastname@example.org )
Example Pyrex modules
# Calculate prime numbers
def primes(int kmax):
cdef int n, k, i
cdef int p
result = 
if kmax > 1000:
kmax = 1000
k = 0
n = 2
while k < kmax:
i = 0
while i < k and n % p[i] <> 0:
i = i + 1
if i == k:
p[k] = n
k = k + 1
n = n + 1
# Defining an extension type
cdef class Spam:
cdef int amount
self.amount = 0
def set_amount(self, new_amount):
self.amount = new_amount
print self.amount, "tons of spam!"