achieving performance using C/C++

S

sandipm

I did fair amount of programming in python but never used c/c++ as
mentioned below.
any good tutorials for using C/C++ to optimize python codebase for
performance?
how widely do they use such kind of mixed coding practices?

sandip

---------- Forwarded message ----------
From: "D.Hering"
..
..
..
..
Python is very easily extended to near C speed. The Idea that FINALLY
sunk in, was that I should first program my ideas in Python WITHOUT
CONCERN FOR PERFOMANCE. Then, profile the application to find the
"bottlenecks" and extend those blocks of code to C or C++. Cython/
Pyrex/Sip are my preferences for python extension frameworks.
..
..
..
..
 
P

Palindrom

Hi all,

I'd be very interseted in a good tutorial for using C/C++ to optimize
python code too !

Thanks in advance.
 
F

Filip Wasilewski

I did fair amount of programming in python but never used c/c++ as
mentioned below.
any good tutorials for using C/C++ to optimize python codebase for
performance?
how widely do they use such kind of mixed coding practices?
[...]

Since you are fluent in Python I also suggest you to start with
Pyrex[1]/Cython[2]. This will let you to express your ideas more
naturally (in a Python-based language) and interface with C code base
without delving much into reference counting, manual parameters
conversion and low-level exception handling.

You will find some tutorials and links to resources and mailing lists
on the projects websites, and if you specify your problem a bit more
then probably someone will be able to give you more precise
references.

For alternatives take a look at [3] and [4]. Try also scanning the
Python Package Index[5] for 'binding', 'wrapper', 'lib' or 'pyrex'
keywords or browse for C/C++ Programming Language category as this
will return some examples of Python extensions.

[1] http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/
[2] http://www.cython.org/
[3] http://www.python.org/doc/faq/extending/#writing-c-is-hard-are-there-any-alternatives
[4] http://docs.python.org/lib/module-ctypes.html
[5] http://pypi.python.org

fw
 
?

=?iso-8859-1?q?Luis_M=2E_Gonz=E1lez?=

mentioned below.
any good tutorials for using C/C++ to optimize python codebase for
performance?
how widely do they use such kind of mixed coding practices?

[...]

Since you are fluent in Python I also suggest you to start with
Pyrex[1]/Cython[2]. This will let you to express your ideas more
naturally (in a Python-based language) and interface with C code base
without delving much into reference counting, manual parameters
conversion and low-level exception handling.

You will find some tutorials and links to resources and mailing lists
on the projects websites, and if you specify your problem a bit more
then probably someone will be able to give you more precise
references.

For alternatives take a look at [3] and [4]. Try also scanning the
Python Package Index[5] for 'binding', 'wrapper', 'lib' or 'pyrex'
keywords or browse for C/C++ Programming Language category as this
will return some examples of Python extensions.

[1]http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/
[2]http://www.cython.org/
[3]http://www.python.org/doc/faq/extending/#writing-c-is-hard-are-there-...
[4]http://docs.python.org/lib/module-ctypes.html
[5]http://pypi.python.org

fw


You might be interested also in ShedSkin.
It is a python to c++ compiler, and it lets you write extension
modules in a restricted subset of python that get automatically
translated to c++. It's still a work in progress although very usable
in its current state (and extremely easy to use).
Its main advantage, compared to Pyrex, is that you don't need to know
c or c++ at all to use it.
Pyrex requires some knowledge about c and its data types in order to
take advantage of its capabilities.
On the other hand, with shedskin you just code in python (getting rid
of its most dynamic features), and this code gets automatically
compiled to a c++ extension module, directly usable from cpython.

Check it out: http://mark.dufour.googlepages.com/

Luis
 

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

No members online now.

Forum statistics

Threads
473,745
Messages
2,569,487
Members
44,909
Latest member
DestinyKetoScam

Latest Threads

Top