[Python-Dev] Status of json (simplejson) in cpython (original) (raw)

Bob Ippolito bob at redivi.com
Sat Apr 16 02:03:55 CEST 2011


On Fri, Apr 15, 2011 at 4:12 PM, Antoine Pitrou <solipsis at pitrou.net> wrote:

On Fri, 15 Apr 2011 14:27:04 -0700 Bob Ippolito <bob at redivi.com> wrote:

On Fri, Apr 15, 2011 at 2:20 PM, Antoine Pitrou <solipsis at pitrou.net> wrote: > Le vendredi 15 avril 2011 à 14:18 -0700, Bob Ippolito a écrit : >> On Friday, April 15, 2011, Antoine Pitrou <solipsis at pitrou.net> wrote: >> >> >> >> > Since the JSON spec is set in stone, the changes >> >> > will mostly be about API (indentation, object conversion, etc) >> >> > and optimization.  I presume the core parsing logic won't >> >> > be changing much. >> >> >> >> Actually the core parsing logic is very different (and MUCH faster), >> > >> > Are you talking about the Python logic or the C logic? >> >> Both, actually. IIRC simplejson in pure python typically beats json >> with it's C extension. > > Really? It would be nice to see some concrete benchmarks against both > repo tips.

Maybe in a few weeks or months when I have time to finish up the benchmarks that I was working on... but it should be pretty easy for anyone to show that the version in CPython is very slow (and uses a lot more memory) in comparison to simplejson. Well, here's a crude microbenchmark. I'm comparing 2.6+simplejson 2.1.3 to 3.3+json, so I'm avoiding integers: * json.dumps: _$ python -m timeit -s "from simplejson import dumps, loads; _  _d = dict((str(i), str(i)) for i in range(1000))" _ "dumps(d)" - 2.6+simplejson: 372 usec per loop - 3.2+json: 352 usec per loop * json.loads: _$ python -m timeit -s "from simplejson import dumps, loads; _  _d = dict((str(i), str(i)) for i in range(1000)); s = dumps(d)" _  "loads(s)" - 2.6+simplejson: 224 usec per loop - 3.2+json: 233 usec per loop The runtimes look quite similar.

That's the problem with trivial benchmarks. With more typical data (for us, anyway) you should see very different results.

-bob



More information about the Python-Dev mailing list