json vs. simplejson

Diez B. Roggisch deets at nospam.web.de
Wed May 13 08:02:53 EDT 2009


Thomas Heller wrote:

> 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?

Dunno about json, but simplejson comes with an (optional) C-based
speedup-module.

Maybe this isn't part of the standard distribution? 

Diez



More information about the Python-list mailing list