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(). Ralf __________________________________________________ Do you Yahoo!? Faith Hill - Exclusive Performances, Videos & More http://faith.yahoo.com
"Ralf W. Grosse-Kunstleve" <rwgk@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@boost-consulting.com * http://www.boost-consulting.com
participants (2)
-
David Abrahams -
Ralf W. Grosse-Kunstleve