json vs. simplejson

T

Thomas Heller

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
 
D

Diez B. Roggisch

Thomas said:
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
 
T

Thomas Heller

Diez said:
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.

Thomas
 
N

Ned Deily

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.
 
T

Thomas Heller

Ned said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top