[Web-SIG] simplejson 2.0.0 released, much faster.
bob at redivi.com
Sat Sep 27 20:16:12 CEST 2008
I spent a fair amount of time this week profiling, benchmarking, and
optimizing simplejson. simplejson 2.0.0 includes the following
* optimized Python encoding path
* optimized Python decoding path
* optimized C encoding path
* optimized C decoding path
* switched to sphinx docs (nearly the same as the json module in python 2.6)
Even without the C speedups, it's several times faster. With the C
speedups, it's WAY faster. I highly recommend that everyone update
their frameworks to use the latest code.
For the primary benchmark I was concerned with (some internal data
structures that Mochi uses) encoding is about 4x faster than cPickle
(!), and decoding is just a tiny bit slower.
There's little excuse to use other libraries now. The fastest
alternative I'm aware of is cjson 1.0.5, which is currently a little
faster than simplejson 2.0.0 when decoding but is actually slower than
simplejson 2.0.0 at encoding (the more important path for people
vending web services). In both cases, simplejson provides more
flexibility (e.g. the decoding object_hook), so a slight speed cost
when decoding is probably to be expected.
There aren't really any API breaking changes, but when decoding a str
input it will return str objects instead of unicode if the str is all
ASCII with no escaped characters. I'm not aware of any scenario other
than doctests where this could be a problem.
More information about the Web-SIG