diff --git a/example/pickle1.cpp b/example/pickle1.cpp index 2f786f69..a1d6101e 100644 --- a/example/pickle1.cpp +++ b/example/pickle1.cpp @@ -1,5 +1,10 @@ /* This example shows how to make an Extension Class "pickleable". + + The world class below can be fully restored by passing the + appropriate argument to the constructor. Therefore it is sufficient + to define the pickle interface method __getinitargs__. + For more information refer to boost/libs/python/doc/pickle.html. */ diff --git a/example/pickle2.cpp b/example/pickle2.cpp index c33776a0..1a3e529c 100644 --- a/example/pickle2.cpp +++ b/example/pickle2.cpp @@ -1,5 +1,20 @@ /* This example shows how to make an Extension Class "pickleable". + + The world class below contains member data (secret_number) that + cannot be restored by any of the constructors. Therefore it is + necessary to provide the __getstate__/__setstate__ pair of pickle + interface methods. + + For simplicity, the __dict__ is not included in the result of + __getstate__. This is not generally recommended, but a valid + approach if it is anticipated that the object's __dict__ will + always be empty. Note that safety guard are provided to catch the + cases where this assumption is not true. + + pickle3.cpp shows how to include the object's __dict__ in the + result of __getstate__. + For more information refer to boost/libs/python/doc/pickle.html. */ diff --git a/example/pickle3.cpp b/example/pickle3.cpp index 19ddec43..e84b7b6e 100644 --- a/example/pickle3.cpp +++ b/example/pickle3.cpp @@ -1,5 +1,15 @@ /* This example shows how to make an Extension Class "pickleable". + + The world class below contains member data (secret_number) that + cannot be restored by any of the constructors. Therefore it is + necessary to provide the __getstate__/__setstate__ pair of pickle + interface methods. + + The object's __dict__ is included in the result of __getstate__. + This requires more code (compare with pickle2.cpp), but is + unavoidable if the object's __dict__ is not always empty. + For more information refer to boost/libs/python/doc/pickle.html. */