Browse Source

Use ujson instead of simplejson

This makes a big difference. About 81% of the WSGI app's time is currently
spent in calls to simplejson.dumps(), which itself takes about 50% more time
than just using 'json' from the standard library under CPython 2.7.

Since simplejson is an old third-party library that relies on C extensions to
get speedups under CPython, it seems fair to replace it with a newer
third-party library, otherwise we are crippling what should be Python's
performance baseline.
Sasha Hart 12 years ago
parent
commit
a29f4365cf
2 changed files with 3 additions and 2 deletions
  1. 2 2
      wsgi/hello.py
  2. 1 0
      wsgi/requirements.txt

+ 2 - 2
wsgi/hello.py

@@ -1,11 +1,11 @@
-import simplejson
+import ujson
 
 
 def app(environ, start_response):
     response = {
       "message": "Hello, World!"
     }
-    data = simplejson.dumps(response)
+    data = ujson.dumps(response)
     response_headers = [
         ('Content-type', 'text/plain'),
         ('Content-Length', str(len(data)))

+ 1 - 0
wsgi/requirements.txt

@@ -0,0 +1 @@
+ujson