[C++-sig] container suite feedback & ideas

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Sat Oct 25 16:06:20 CEST 2003

Hi Raoul,

Using your documentation I've had no problems wrapping three custom
linear array types with your container suite. Just a couple of minor

static boost::python::indexing::IndexStyle const index_style

typedef std::map<std::string, int> Container;

typedef indexing::map_algorithms<simple_map_traits> Algorithms;

I believe according to the boost naming conventions these identifiers
must be all lower case. But I am not really an authority in this
matter. David?

> #include "algo_selector.hpp"
> #include "visitor.hpp"

Should probably be #include <boost/...>. It wasn't clear to me
what I had to include. Eventually just including

#include <boost/python/suite/indexing/container_suite.hpp>

worked for my purposes. Is this what I should be doing?
Should this be added to <boost/python.hpp>?

There are two important features I am wondering about:

1. Just doing this

     .def(indexing::container_suite<my_container, my_algorithms>())

   doesn't enable me to initialize the instances with Python
   lists or tuples. Have you thought about this already?
   My first idea would be to define custom rvalue converters from
   Python sequences to the wrapped container type
   Then one could pass a Python sequence anywhere the wrapped container
   is used as a const& or by-value argument. Simply define Python
   bindings for the C++ copy constructor to enable initialization with
   Python sequences.

2. Pickling of the wrapped types. This is a big issue but I find
   it absolutely essential. I have a fairly general solution
   that I'd be happy to share and extend if there is an interest.
   If you are curious, it is a three-layer system:
   The low-level serialization code for built-in types is here:
   This is designed to maximize portability but is also very fast.
   The second layer is here:
   pickle_single_buffered.h and pickle_double_buffered.h.
   A top layer for a particular array type is here:
   flex_pickle_single_buffered.h, flex_pickle_double_buffered.h.
   The system also works for user-defined types (the user has
   to supply some code).
   Adapting this system for the container suite would probably
   require significant changes only to the top layer.


Do you Yahoo!?
The New Yahoo! Shopping - with improved product search

More information about the Cplusplus-sig mailing list