Ola. So I was working on a project and noticed that json encoding/decoding of a string to string dictionary was taking... uhhh 70% of the time. The are a few other benchmarks out there (kbyanc, hill-street), but none including the new simplejson 1.8.1 which has extensions to improve performance (links below).
I'm only serializing dictionary mapping strings to strings. Maybe occasionally dict within a dict, but always primitive types. I don't need special ways of serializing custom objects. This test is just raw primitive types and data structure performance.
For this test, I made two dictionary with a dozen entries. One has both keys and value as ascii regular python strings, the other had the same data but used unicode strings.
Serialization, cjson, ascii: 94 Serialization, cjson, unicode: 117 Deserialization, cjson, ascii: 80
This version has c-extensions for both encode and decode
Serialization, simplejson, ascii: 549 Serialization, simplejson, unicode: 592 Deserialization, simplejson, ascii: 2068
This version is 100% pure python. It can be grabbed here
Serialization, simplejson, ascii: 2150 Serialization, simplejson, unicode: 1744 Deserialization, simplejson, ascii: 3318
Well, guess which version I'll be using. simplejson has all sorts of other features that you might want. Sometimes speed isn't everything, but for my application it is. Enjoy!