dave at boost-consulting.com
Tue Dec 6 20:21:59 CET 2005
The following message is a courtesy copy of an article
that has been posted to gmane.comp.lib.boost.user as well.
"Drumheller, Michael" <michael.drumheller at boeing.com> writes:
>>> From: David Abrahams <dave <at> boost-consulting.com>
>>> Subject: Re: Boost.python serialization
>>> Newsgroups: gmane.comp.lib.boost.user
>>> Date: 2005-11-29 23:28:17 GMT (6 days, 17 hours and 9 minutes ago)
>>> "Drumheller, Michael" <michael.drumheller <at> boeing.com> writes:
>>> > Thank you for the help. I have seen that link (the one you supplied)
>>> > before, but I posted my question because that link in particular does
>>> > not mention the words "Boost.Serialization" or "Archive" at all.
>>> That's because the Boost Serialization library is unrelated.
> I understand that it is technically unrelated. I am asking for
> information about about patterns of actual usage.
I'm afraid I don't know that.
>>> > I suppose what I was really getting at, and was probably not very
>>> > clear about (sorry :| ) was whether the specific approach (by
>>> > N. Becker) of using a stringstream wrapped with a
>>> > boost::archive::binary_oarchive is a standard idiom.
> OK: "common," "popular," "preferred," "regarded-as-best-practice,"
>>> > (Basically, I would have thought that "python pickle boost::archive"
>>> > would be a million-hit Google query, but it's only about a dozen. I
>>> > find that weird. Do people just not serialize their C++ extensions
>>> > very often?)
>>> Yes, they do it very often. There's usually no need to touch
>>> Boost.Serialization in order to do so, though.
> My extensions refer to one another, i.e., they form a significant object
> hierarchy in and of themselves. E.g., on the C++ side I might have an
> instance x of class X, which contains a vector of shared_ptrs p1,...,pn
> to instances y1,...,yn of another C++ class Y. At pickle-time there may
> be Python object z with a member u bound to to x and members w1,...,wm
> bound to a subset of the y1,...,yn. Is it even feasible to expect to be
> able to simple pickle.dump z and have it all work?
Yes. Of course you have to do some work in your wrapping code to say
how X gets pickled.
> Please keep in mind: I am just getting started wading into serializing
> a pretty complicated set of strongly interdependent Python and C++
> objects and I am just trying to get my bearings. If this is the wrong
> forum to be asking these questions, please tell me.
Well, the C++-sig _might_ be more appropriate:
http://www.boost.org/more/mailing_lists.htm#cplussig (cross-posted there)
We (Boost Consulting) are actually planning to do something like this
with one of our clients, but we haven't gotten started with it yet. I
think everything should "just work" as long as you take care not to
try to serialize the same object both from the C++ side (using
Boost.Serialization) and from the Python side (using pickle). Because
each system implements its own object tracking, you could end up
representing the same object twice.
More information about the Cplusplus-sig