[C++-sig] [Py++] C++ containers and Python sequences

peoro peoro.noob at gmail.com
Tue Feb 2 16:53:16 CET 2010


Hello,
let me start by thanking everybody who's behind Boost.Python and Py++,
these projects are really awesome.

I read that Py++ (and/or Boost.Python) has a native support for some
C++ containers, and that others can be added using indexing suites [
http://www.language-binding.net/pyplusplus/documentation/containers.html
]; was thus expecting a native conversions between C++ containers and
Python sequences.
For example, by exposing bindings for the following C++ function:
void f( const std::vector<int> &v );
I supposed the next Python expression would have been valid:
mypackage.f( [1,2,3] );
but actually it's not.
Only std::string gets automagically converted to/from str, other
supported containers can be explicitly casted to Python sequences (eg:
passing an exposed std::vector<int> to Python's "list", it works), but
not the other way around.

I've been trying to play with pyplusplus.module_builder, but cannot
find a way to allow native conversions, and google isn't being of help
either.
Is it possible to achieve native conversions, and, if it is, why is it
not done by default?

Thanks!
Paolo Giangrandi


More information about the Cplusplus-sig mailing list