ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> cpp-sig
cpp-sig
[C++-sig] container suite feedback & ideas
by Ralf W. Grosse-Kunstleve other posts by this author
Oct 25 2003 7:03AM messages near this date
[C++-sig] Improved version of Lijun Qin's multithreading patch | [C++-sig] Re: Extracting C++ objects: documentation example fails.
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
remarks:

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

   class_<my_container> ("my_container")
     .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
   (http://www.boost.org/libs/python/doc/v2/faq.html#question2).
   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:
    
http://cvs.sourceforge.net/viewcvs.py/cctbx/scitbx/include/scitbx/serialization/
   This is designed to maximize portability but is also very fast.
   The second layer is here:
    
http://cvs.sourceforge.net/viewcvs.py/cctbx/scitbx/include/scitbx/boost_python/
   pickle_single_buffered.h and pickle_double_buffered.h.
   A top layer for a particular array type is here:
    
http://cvs.sourceforge.net/viewcvs.py/cctbx/scitbx/include/scitbx/array_family/boost_python/
   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.

Ralf


__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

_______________________________________________
C++-sig mailing list
C++-sig@[...].org
http://mail.python.org/mailman/listinfo/c++-sig

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved