473,545 Members | 1,930 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Opinion on Pyrex

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
Sep 30 '05 #1
4 1631
"Carl" <ph***********@ chello.se> wrote:
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
Sep 30 '05 #2
Carl wrote:
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
rk***@ucsd.edu

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

Sep 30 '05 #3
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++.

Sep 30 '05 #4
Don
Carl wrote:
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
Sep 30 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2285
by: Gary Stephenson | last post by:
I'm getting a clean generate, compile and link from my .pyx script, but when I attempt to run the resultant .exe, I get: "The procedure entry point Py_NoneStruct could not be located in the dynamic link library python23.dll" Can anybody provide me with a clue here? I've already cut down my script to remove all references to None,...
10
2021
by: Kyler Laird | last post by:
I need to submit C/C++ code for a class. (It's not a programming class. The choice of language is inertial. I think that it mostly serves to distract students from the course subject.) I'm fairly fluent with C but it hurts to think about writing in C when Python is *so* much more appropriate for these operations. I'd like to keep my...
1
1664
by: Paul Prescod | last post by:
PyCon 2004 Slides on "Extending Python with Pyrex" PDF: http://www.prescod.net/pyrex/ExtendingPythonWithPyrex.pdf PPT: http://www.prescod.net/pyrex/ExtendingPythonWithPyrex.ppt Pycon 2004 Slides on "Optimizing Python code with Pyrex" PDF: http://www.prescod.net/pyrex/OptimizingPythonWithPyrex.pdf PPT:...
4
2064
by: Kyler Laird | last post by:
I mentioned earlier that I started using Pyrex because I'm taking a computer vision course that requires all assignments to be submitted as C(++). While I could write C it would hurt me to do so and certainly distract me from the computer vision aspects. I like using Python these days and Pyrex looked like a good solution. (BTW, on the...
6
1929
by: SeeBelow | last post by:
I just read "about Pyrex" at http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/version/Doc/About.html It seems that it is not compiled into machine code, as C would be, and therefore it does not offer the only valid reason for using C, which is for an increase in execution speed. The word "speed" does not appear on the above web page. ...
1
3571
by: Martin Bless | last post by:
Now that I've got my extension building machine using the VC++ Toolkit 2003 up and running I'm keen on using Pyrex (Pyrex-0.9.3, Python-2.4.0). But the definition of the swig_sources() method seems to have changed. When I try to build the examples from Pyrex I get a TypeError: c:\Pyrex-0.9.3\Demos> python Setup.py build_ext --inplace
27
3949
by: Julien Fiore | last post by:
Do you wand to install Pyrex on Windows ? Here is a step-by-step guide explaining: A) how to install Pyrex on Windows XP. B) how to compile a Pyrex module. Julien Fiore, U. of Geneva
11
1974
by: Jim Lewis | last post by:
Has anyone found a good link on exactly how to speed up code using pyrex? I found various info but the focus is usually not on code speedup.
7
2034
by: Jim Lewis | last post by:
I'm trying to move a function into pyrex for speed. The python side needs to pass a list to the pyrex function. Do I need to convert to array or something so pyrex can generate tight code? I'm not clear how to do this.
0
7411
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7669
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7926
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7439
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7773
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5987
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5343
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
1
1028
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
722
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.