Opinion on Pyrex

C

Carl

I have recently started to use Pyrex and am amazed by it's useability.

Are there any alternatives to Pyrex?

One thing that I haven't figured out is how to embed pure C/C++ source code
into Pyrex. For example, if you have a bunch of C files that you want to
use together with some Python code snippets, how do you practically achieve
this using Pyrex? I have come to the conclusion that it is not possible
without some rewriting and adaptation (translation) of available C source
code (if you don't want to compile and link all your C source into a
statical or dynamical library).

Carl
 
G

George Sakkis

Carl said:
I have recently started to use Pyrex and am amazed by it's useability.

Are there any alternatives to Pyrex?

One thing that I haven't figured out is how to embed pure C/C++ source code
into Pyrex. For example, if you have a bunch of C files that you want to
use together with some Python code snippets, how do you practically achieve
this using Pyrex? I have come to the conclusion that it is not possible
without some rewriting and adaptation (translation) of available C source
code (if you don't want to compile and link all your C source into a
statical or dynamical library).

Carl

You may want to check out weave: http://www.scipy.org/documentation/weave/

George
 
R

Robert Kern

Carl said:
I have recently started to use Pyrex and am amazed by it's useability.

Are there any alternatives to Pyrex?

One thing that I haven't figured out is how to embed pure C/C++ source code
into Pyrex. For example, if you have a bunch of C files that you want to
use together with some Python code snippets, how do you practically achieve
this using Pyrex? I have come to the conclusion that it is not possible
without some rewriting and adaptation (translation) of available C source
code (if you don't want to compile and link all your C source into a
statical or dynamical library).

I always just include those C files as sources for the Extension along
with the Pyrex-generated file.

--
Robert Kern
(e-mail address removed)

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
 
L

Lisandro Dalcin

That's the reason I am using SWIG

http://www.swig.org

For C++ classes, you can get a working Python module autmatically. It
also has advanced features, like "directors", enablig subclassing from
Python (to be used in de C++ side).

However, I should warn you SWIG is not as friendly as Pyrex. But I used
it to wrap nontrivial libraries written in C and C++.
 
D

Don

Carl said:
I have recently started to use Pyrex and am amazed by it's useability.

Are there any alternatives to Pyrex?

One thing that I haven't figured out is how to embed pure C/C++ source
code into Pyrex. For example, if you have a bunch of C files that you want
to use together with some Python code snippets, how do you practically
achieve this using Pyrex? I have come to the conclusion that it is not
possible without some rewriting and adaptation (translation) of available
C source code (if you don't want to compile and link all your C source
into a statical or dynamical library).

Carl

I'm not sure exactly where you're having problems, but that's what extern
cdef's are for. Then you can add the source modules to setup.py, just like
you do with the pyrex source. You'll probably gather by now that you're
building with distutils, not pyrexc.

I've done this on Windows, haven't tried in on other platforms.

Don
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top