json vs. simplejson

Thomas Heller theller at python.net
Wed May 13 07:51:33 EDT 2009


Python 2.6 contains the json module, which I thought was the renamed (and improved?)
simplejson module that also works on older Python versions.

However, it seems the json is a lot slower than simplejson.
This little test, run on Python 2.6.2 and WinXP shows a dramatic difference:

  C:\>py26 -m timeit -s "from json import dumps, loads" "loads(dumps(range(32)))"
  1000 loops, best of 3: 618 usec per loop

  C:\>py26 -m timeit -s "from simplejson import dumps, loads" "loads(dumps(range(32)))"
  10000 loops, best of 3: 31 usec per loop

Does anyone have an explanation for that?

Thanks,
Thomas



More information about the Python-list mailing list