json vs. simplejson

Thomas Heller theller at python.net
Wed May 13 14:58:10 EDT 2009


Ned Deily schrieb:
> In article <76vs9tF1f6c58U1 at mid.individual.net>,
>  Thomas Heller <theller at python.net> wrote:
>> Diez B. Roggisch schrieb:
>> > 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? 
>> json has it's own _json speedup module.  And funny, on Linux, json
>> WITH _json is still somewhat slower (~10%) than simplejson WITHOUT
>> the _speedups module.
> 
> According to the svn history in 2.6, the json module was a copy of 
> simplejson 1.9.  The current version of simplejson is 2.0.9 and, 
> according to its CHANGES.txt, there have been a number of performance 
> improvements in the various releases since 1.9.  Looks like the trunk 
> (2.7) version of json has been updated to the latest simplejson.
> 

Ok, thanks.  I've submitted a bug for python2.6, but it seems they
will not upgrade to a newer version.
<http://bugs.python.org/issue6013>

Thomas



More information about the Python-list mailing list