Issue 6013: json slower than simplejson (original) (raw)

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:48 admin set github: 50263
2009-05-13 15:07:26 pitrou set status: open -> closedresolution: wont fixmessages: +
2009-05-13 14:55:55 theller set messages: +
2009-05-13 14:38:08 pitrou set nosy: + pitroumessages: +
2009-05-13 14:33:00 theller create