Pickling support will be a major advancement for Mapnik as it will allow for:
1) maps (or sub objects) to be serialized in binary form, which will be potentially 1000's of times faster to load than xml and
2) allow for bundling of map objects along with other pickled info (think rendering directives, auxillary styles, serialized data - geojson) and
3) will allow for serialization of Map state as well as the basic styles and layers and
4) will be easy to marshall into pickle-based datastores (think custom django fields or couchdb) and
5) will have potentially lots of other uses
I've added pickling support to a few of the main container objects exposed in the Python bindings. But many more objects need pickling support added.
Copy and Deepcopy are supported in boost via the same support needed for pickling.
We need to discuss how to accomplish this (fairly) extensive task to complete full pickle/deepcopy support of Mapnik objects in python, and this ticket will track status (and super-cede other pickle-related tickets).
List of boost python cpp files that need pickle/copy support added or extended:
[springmeyer] Note: this ticket condenses/super-cedes #233, #234, #167
[springmeyer] and #205
[springmeyer] Objects that need pickling are:
[springmeyer] mapnik.Coord pickling added in r1147
[springmeyer] problem with layer pickling fixed in r1148
[springmeyer] pickling of styles fixed in r1149
[springmeyer] via brentp: http://code.google.com/p/pickled-object-database/
cc'ed josh re: stylecache
[springmeyer] fix'ed josh's email
[springmeyer] Note: I've begun work on source:trunk/bindings/python/mapnik_rule.cpp, which is the big boost::visitor dispatch spot. But, I've run out of time to get it working. If anyone starts working on it get in touch.
[springmeyer] added pickling support for PointSymbolizer in r1295. We should in the future look into pickling the actual image data...
[springmeyer] slight fix to TextSymbolizer pickling in r1298 - removing the attempt to pickle fonsets as they are not even exposed in python bindings yet (see: #348)
[springmeyer] another fix to TextSymbolizer in r1314
[springmeyer] r1342, r1344 added large patch to finish full draft support for pickling all Map objects
over time it has proven to be hard to keep all symbolizer pickle methods up to date, and while python pickling can be quite valuable for key api objects like mapnik.Box2d or mapnik.Query - that store state - the entire pickling of maps has not been a pressing need. What would be extremely useful is the ability to quickly clone map objects from any binding language - not just python. That is now handled in #1390. Also, serialization could be handled by moving to json based maps, but that is a separate issue that will be tied to Carto CSS syntax (see #905).
So, we should remove pickling from symbolizers and any other places where pickling does not have a strong usecase if we support map deepcopy (as per #1390).
closing, will handling tracking removal at #1391