This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: json slower than simplejson
Type: performance Stage:
Components: Versions: Python 2.6
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: pitrou, theller
Priority: normal Keywords:

Created on 2009-05-13 14:33 by theller, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg87685 - (view) Author: Thomas Heller (theller) * (Python committer) Date: 2009-05-13 14:32
The json package is a lot slower than the simplejson package.  Both
packages have their C compiled speedup module; however:

  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

This is on Windows XP, with Python 2.6.2.
msg87686 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-05-13 14:38
This is probably because your simplejson is much more recent than the
json version shipped with 2.6.
Can you try again with trunk and post the numbers?
msg87687 - (view) Author: Thomas Heller (theller) * (Python committer) Date: 2009-05-13 14:55
Here are the numbers from trunk (rev ) and release26-maint branch (rev ):

c:\svn\release26-maint\PCbuild>python -m timeit -s "from json import loads, dumps" "loads(dumps(range(32)))"
1000 loops, best of 3: 726 usec per loop

c:\svn\release26-maint\PCbuild>cd ..\..\trunk\PCbuild

c:\svn\trunk\PCbuild>python -m timeit -s "from json import loads, dumps" "loads(dumps(range(32)))"
10000 loops, best of 3: 33.5 usec per loop

So, the performance issue seems fixed in trunk but not in release26-maint.

(This stuff is an issue for me since I want to use jsonrpc on
an embedded system.  Cross-compiling Python is a pain, but installing
simplejson which uses setuptools is even more painful.)
msg87688 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-05-13 15:07
Given the amount of changed code between the two simplejson versions,
I'm afraid there's no way the new version will be backported to
release26-maint. You can probably do the backport manually in your
Python install, though (or bite the bullet and use SVN trunk, which is
rather stable currently).
History
Date User Action Args
2022-04-11 14:56:48adminsetgithub: 50263
2009-05-13 15:07:26pitrousetstatus: open -> closed
resolution: wont fix
messages: + msg87688
2009-05-13 14:55:55thellersetmessages: + msg87687
2009-05-13 14:38:08pitrousetnosy: + pitrou
messages: + msg87686
2009-05-13 14:33:00thellercreate