Skip to content

Instantly share code, notes, and snippets.

@jiaaro
Created May 6, 2015 23:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jiaaro/08d47ca365b8e53ab753 to your computer and use it in GitHub Desktop.
Save jiaaro/08d47ca365b8e53ab753 to your computer and use it in GitHub Desktop.
ujson timings
# Timings taken on a MacBook Pro (Retina, 15-inch, Mid 2014)
# running OS X 10.10.3
In [1]: import sys
In [2]: print sys.version
2.7.6 (default, Sep 9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)]
In [3]: data = [{str(x): y+z for x in range(10) for y in range(50)} for z in range(500)]
In [4]: import json
In [5]: import ujson
In [6]: %timeit json.dumps(data)
1000 loops, best of 3: 859 µs per loop
In [7]: %timeit ujson.dumps(data)
1000 loops, best of 3: 317 µs per loop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment