mirror of
https://github.com/ultrajson/ultrajson.git
synced 2024-11-24 05:12:02 +01:00
Ultra fast JSON decoder and encoder written in C with Python bindings
dectest | ||
msvc9 | ||
python | ||
Makefile | ||
README | ||
ultrajson.h | ||
ultrajsondec.c | ||
ultrajsonenc.c |
UltraJSON is a fast and extendable JSON encoder and decoder written in pure C Python bindings are available as the module ujson (through easy_install / pypi): http://pypi.python.org/pypi/ujson/ Installation instructions: 1. Build and install ujson Python extension (requires root) Go to <root>/python Type: python setup.py build install 2. Run tests (as needed) Type: python tests.py Same instructions applies for Windows except that step 1) isn't necessary since a prebuilt static library is included. Preliminary benchmarks: 64-bit benchmarks Linux Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56) OS Version: Ubuntu 10.10 System Type: x64-based PC Processor: Intel(R) Core(TM) i5-2300 CPU @ 2.80GHz Total Physical Memory: 4096 MB Array with 256 utf-8 strings: ujson encode : 2714.66499 calls/sec simplejson encode : 1542.63718 calls/sec cjson encode : 132.23604 calls/sec ujson decode : 2079.17287 calls/sec cjson decode : 992.21602 calls/sec simplejson decode : 278.92061 calls/sec Medium complex object: ujson encode : 17849.80356 calls/sec simplejson encode : 3524.32372 calls/sec cjson encode : 2967.34656 calls/sec ujson decode : 11685.87610 calls/sec cjson decode : 8206.67906 calls/sec simplejson decode : 6549.99750 calls/sec Array with 256 strings: ujson encode : 38543.50303 calls/sec simplejson encode : 19436.45772 calls/sec cjson encode : 12392.55614 calls/sec ujson decode : 27207.33157 calls/sec cjson decode : 30237.60827 calls/sec simplejson decode : 25271.93073 calls/sec Array with 256 doubles: ujson encode : 6027.45931 calls/sec simplejson encode : 2915.54871 calls/sec cjson encode : 3546.88804 calls/sec ujson decode : 28045.13375 calls/sec cjson decode : 15066.73209 calls/sec simplejson decode : 15604.98222 calls/sec Array with 256 True values: ujson encode : 187342.39634 calls/sec simplejson encode : 48972.93887 calls/sec cjson encode : 67274.93082 calls/sec ujson decode : 158103.79663 calls/sec cjson decode : 83237.88990 calls/sec simplejson decode : 115645.98241 calls/sec Array with 256 dict{string, int} pairs: ujson encode : 25301.85690 calls/sec simplejson encode : 5734.29472 calls/sec cjson encode : 4447.73411 calls/sec ujson decode : 16290.72288 calls/sec cjson decode : 12528.56060 calls/sec simplejson decode : 10394.23358 calls/sec Dict with 256 arrays with 256 dict{string, int} pairs: ujson encode : 87.40865 calls/sec simplejson encode : 17.07889 calls/sec cjson encode : 17.25164 calls/sec ujson decode : 45.94026 calls/sec cjson decode : 34.60225 calls/sec simplejson decode : 26.92238 calls/sec 32-bit benchmarks Windows Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] OS Version: 6.1.7601 Service Pack 1 Build 7601 System Type: x64-based PC Processor: Intel(R) Core(TM)2 Quad CPU Q9550 @ 2.83GHz 2.83 GHz Total Physical Memory: 8191 MB Array with 256 utf-8 strings: ujson encode : 1191.98175 calls/sec simplejson encode : 1013.98279 calls/sec cjson encode : 1040.66063 calls/sec ujson decode : 1215.66875 calls/sec cjson decode : 493.30484 calls/sec simplejson decode : 269.85512 calls/sec Medium complex object: ujson encode : 10307.63723 calls/sec simplejson encode : 2534.94769 calls/sec cjson encode : 2047.95118 calls/sec ujson decode : 7274.10026 calls/sec cjson decode : 3575.39307 calls/sec simplejson decode : 3565.51252 calls/sec Array with 256 strings: ujson encode : 21348.25210 calls/sec simplejson encode : 15736.74638 calls/sec cjson encode : 6371.26334 calls/sec ujson decode : 26050.25316 calls/sec cjson decode : 16468.88215 calls/sec simplejson decode : 21115.75770 calls/sec Array with 256 doubles: ujson encode : 26975.49110 calls/sec simplejson encode : 2046.29746 calls/sec cjson encode : 2133.56594 calls/sec ujson decode : 28430.33722 calls/sec cjson decode : 4114.36400 calls/sec simplejson decode : 4419.08507 calls/sec Array with 256 True values: ujson encode : 89846.12897 calls/sec simplejson encode : 34288.36862 calls/sec cjson encode : 47168.35849 calls/sec ujson decode : 99423.47549 calls/sec cjson decode : 58795.91460 calls/sec simplejson decode : 76296.14699 calls/sec Array with 256 dict{string, int} pairs: ujson encode : 14776.41614 calls/sec simplejson encode : 3876.86634 calls/sec cjson encode : 3050.65343 calls/sec ujson decode : 12934.39432 calls/sec cjson decode : 7993.04345 calls/sec simplejson decode : 7152.09475 calls/sec Here is the benchmark run from a 32bit CentOS 5.6 (Python 2.4) machine: Array with 256 utf-8 strings: ujson encode : 1453.30891 calls/sec simplejson encode : 658.31181 calls/sec cjson encode : 62.18416 calls/sec ujson decode : 1016.58767 calls/sec cjson decode : 455.28550 calls/sec simplejson decode : 124.20439 calls/sec Medium complex object: ujson encode : 6010.21634 calls/sec simplejson encode : 1418.77823 calls/sec cjson encode : 1252.92530 calls/sec ujson decode : 4637.52630 calls/sec cjson decode : 3444.13604 calls/sec simplejson decode : 2166.18641 calls/sec Array with 256 strings: ujson encode : 12252.28889 calls/sec simplejson encode : 9351.67532 calls/sec cjson encode : 7786.13697 calls/sec ujson decode : 10951.17394 calls/sec cjson decode : 15971.02425 calls/sec simplejson decode : 6796.77480 calls/sec Array with 256 doubles: ujson encode : 16300.61218 calls/sec simplejson encode : 1613.39428 calls/sec cjson encode : 2035.58937 calls/sec ujson decode : 17301.00746 calls/sec cjson decode : 5785.33627 calls/sec simplejson decode : 6199.49364 calls/sec Array with 256 True values: ujson encode : 72618.15350 calls/sec simplejson encode : 18707.57593 calls/sec cjson encode : 24150.26201 calls/sec ujson decode : 53650.94162 calls/sec cjson decode : 48069.53050 calls/sec simplejson decode : 47098.40293 calls/sec Array with 256 dict{string, int} pairs: ujson encode : 8811.85922 calls/sec simplejson encode : 2756.91262 calls/sec cjson encode : 1758.26962 calls/sec ujson decode : 6490.36358 calls/sec cjson decode : 6330.77263 calls/sec simplejson decode : 4161.97048 calls/sec Dict with 256 arrays with 256 dict{string, int} pairs: ujson encode : 31.08834 calls/sec simplejson encode : 10.41434 calls/sec cjson encode : 6.93790 calls/sec ujson decode : 19.81373 calls/sec cjson decode : 20.31727 calls/sec simplejson decode : 15.05690 calls/sec See (python/benchmark.py) for further information. NOTE: These benchmarks are preliminary!