[Tutor] Wrapper of C++

Dave Angel davea at ieee.org
Thu Oct 8 19:44:34 CEST 2009


Lizhi Yang wrote:
> Since the memory usage for saving huge data using python is not
> efficent at all(12 bytes per int). if I want to implement algorithms
> and load the huge amount of data using C++, but using Python as the
> glue language to implement other functionality such as Gui and txt
> processing, you think Boost.python is better or SWIG is better? Have
> not tried yet,
> just need to make decision first, thanks.
>
>   
arrays of ints don't take 12 bytes per, they take 4.  That's the same in 
C++ or in Python.  So if that's the only reason to use C++, stick with 
Python.  Probably you were looking at the overhead of list, which lets 
you put different types of data in different offsets.  If you really 
have an (huge) array of ints, use array.array() to create it.

As for talking between C++ and Python, you have a number of choices.  
You probably should look at ctypes, since it's built-in, before trying 
something more complex.

DaveA


More information about the Tutor mailing list