Hi,
As part of a research project I'm working on, I found it convenient to be able to pickle messages (or more specifically Python structures that contain them). You can do this without patching protobuf, but it is a bit clumsier and (unless I'm missing something) requires registering a handler for every kind of message to be handled with copy_reg, or breaking down the structures manually (especially annoying when operating interactively).
The attached patch adds __getstate__ and __setstate__ methods to generated classes, hooking into pickle and using SerializePartialToString to return an object pickle knows how to deal with, allowing them to be pickled out of the box. This seems to work for both standard Python messages and the experimental C++ bindings.
I'm not sure whether this is a common use case, but it solved my problem nicely, and seems like something that should just work, and therefore I contribute it upstream.
Alex