speeding things up with C++

Chris Mellon arkanes at gmail.com
Thu May 31 13:25:17 EDT 2007


On 31 May 2007 03:45:32 -0700, bullockbefriending bard
<kinch1967 at gmail.com> wrote:
> Thanks this is good news. I think my C/C++ background is sufficient to
> manage to figure things out if I RTFM carefully.
>
> Basically I want to pass in a Python list of integer tuples, create an
> STL container full of equivalent tuples, apply some processor-
> intensive algorithm to said list of tuples, and finally poke the
> results back into another Python list of integer tuples and return it
> to the calling Python environment. Data structures are well-defind and
> simple, and the most complex case would be 3-deep nested list, so I
> will seriously consider figuring out how to do it manually as you
> suggest.
>

Are you sure you want an STL container? Since the primary operator
here is Python, the extra benefits from the STL container over plain C
arrays isn't as evident.

Pyrex is a good way to write the interface between your C++ code and
the Python code - it handles the refcounting and boilerplate for you -
and perhaps for writing the algorithms as well, depending on how
complicated and performance sensitive they are.

Also, using numeric/Numarray can be a very big win. It can potentially
save you a fair amount of marshalling overhead.



More information about the Python-list mailing list