[C++-sig] deepcopy

David Abrahams dave at boost-consulting.com
Mon Oct 7 05:58:35 CEST 2002


"Ralf W. Grosse-Kunstleve" <rwgk at yahoo.com> writes:

> Sometimes I need to make a copy of a wrapped C++ object in Python. Python's
> copy.deepcopy() will only work for objects that are pickleable. I am wondering
> if it wouldn't be easy to make the C++ copy constructor available by default in
> Python, for example through the member functon .copy(). That would be much more
> convenient than .def'ing copy for everything explicitly. Similar to "no_init"
> there could be a "no_copy" to suppress the automatic generation of .copy().

We already have boost::noncopyable for that purpose.

I'm not sure we should generate .copy() automatically, but maybe we
should have a def_copy() method.

Food for thought.

-- 
           David Abrahams * Boost Consulting
dave at boost-consulting.com * http://www.boost-consulting.com





More information about the Cplusplus-sig mailing list