I've just revved jsonlib2, the C-based json parser used at metaweb for
freebase.com. Compared with simplejson, my initial tests have it
between 21 and 25 times faster for loads() and around 10x faster for
dumps()

http://code.google.com/p/jsonlib2/

For those of you who have never used jsonlib/jsonlib2, all you have to
know is that with this version, jsonlib2 is much more compatible with
simplejson/json. Got a ways to go but for most applications it should
be a drop-in replacement.

This is the first C Python extension I've ever written, and I actually
inherited most of the code when I forked jsonlib because of
differences with the author. This means I'm very interested in patches/
critiques/etc.

For those using jsonlib or jsonlib2:

Version 1.5 is a big API change - loads() and dumps() are now almost
completely compatible with simplejson's loads() and dumps() - so it
really should be a drop-in replacement. Here are a few things that
have been possible with simplejson, but not with jsonlib2:

1) looser enforcement of json spec - allowing stuff like:
>>> jsonlib2.dumps({None: "foo"})
'{"null": "foo"}'

>>> jsonlib2.dumps(None)
'null'

2) full support for Infinity, NaN, in both dumping AND parsing, by
default:
>>> jsonlib2.dumps(1e10000)
'Infinity'
>>> jsonlib2.loads(jsonlib2.dumps(1e10000))
inf

I've actually imported the simplejson unit tests, and this library
passes 26 of 32 tests, and most failures are just due to the fact that
jsonlib2 prefers to output in utf8 rather than unicode, for faster
output from a web server.

Alec
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

        Support the Python Software Foundation:
        http://www.python.org/psf/donations.html

Reply via email to