forked from ultrajson/ultrajson
-
Notifications
You must be signed in to change notification settings - Fork 0
Ultra fast JSON decoder and encoder written in C with Python bindings – Modified version implementing DateTimes support to try to speed up PyES. See https://github.com/pelletier/pyes
License
pelletier/ultrajson
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
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 Benchmarks: 64-bit benchmarks Linux Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53) OS Version: Ubuntu 11.04 System Type: x64-based PC Processor: Intel(R) Core(TM) i5-2300 CPU @ 2.80GHz Total Physical Memory: 4096 MB py-yajl 0.3.5 => http://rtyler.github.com/py-yajl simplejson 2.1.2 => http://simplejson.readthedocs.org/en/latest/index.html cjson 1.0.5 => http://pypi.python.org/pypi/python-cjson Note: Some of the string benchmarks are unfair as much of the final performance depends on to what extent the individual JSON encoders/decoders implement the JSON specification and Unicode standard. At the time of writing py-yayl and cjson did not fully comply to the JSON specification and Unicode standard. Array with 256 utf-8 strings: *yajl encode : 5132.81010 calls/sec ujson encode : 2793.22602 calls/sec simplejson encode : 1609.20858 calls/sec cjson encode : 139.65933 calls/sec *) Output not ASCII but UTF-8 (default escaping behaviour not implemented) ujson decode : 1404.18567 calls/sec cjson decode : 814.54848 calls/sec yajl decode : 594.28917 calls/sec simplejson decode : 347.25104 calls/sec Medium complex object: ujson encode : 18757.01101 calls/sec yajl encode : 6315.14030 calls/sec simplejson encode : 5542.03928 calls/sec cjson encode : 4651.59072 calls/sec ujson decode : 10759.69649 calls/sec simplejson decode : 8148.35221 calls/sec cjson decode : 7931.04387 calls/sec yajl decode : 5887.38201 calls/sec Array with 256 strings: ujson encode : 40427.72790 calls/sec yajl encode : 23158.54336 calls/sec simplejson encode : 22544.31270 calls/sec cjson encode : 12726.16278 calls/sec *simplejson decode : 28077.25572 calls/sec ujson decode : 26161.35785 calls/sec cjson decode : 25661.96211 calls/sec yajl decode : 13565.59414 calls/sec *) Specific decoder advantage from 8-bit strings (character encoding not preserved) Array with 256 doubles: cjson encode : 10890.30488 calls/sec yajl encode : 6335.60567 calls/sec ujson encode : 6035.47694 calls/sec simplejson encode : 4153.79495 calls/sec ujson decode : 27824.38869 calls/sec simplejson decode : 12599.16997 calls/sec yajl decode : 11014.36990 calls/sec cjson decode : 8082.23784 calls/sec Array with 256 True values: ujson encode : 189406.12793 calls/sec yajl encode : 97727.04396 calls/sec cjson encode : 73106.77801 calls/sec simplejson encode : 50481.90233 calls/sec ujson decode : 148107.72025 calls/sec simplejson decode : 125620.84065 calls/sec cjson decode : 76946.51962 calls/sec yajl decode : 73256.86109 calls/sec Array with 256 dict{string, int} pairs: ujson encode : 26391.91864 calls/sec yajl encode : 12496.90579 calls/sec simplejson encode : 6294.72548 calls/sec cjson encode : 5044.07534 calls/sec ujson decode : 16069.25600 calls/sec cjson decode : 13145.57687 calls/sec simplejson decode : 10464.16719 calls/sec yajl decode : 8713.18458 calls/sec Dict with 256 arrays with 256 dict{string, int} pairs: ujson encode : 93.33057 calls/sec yajl encode : 47.37864 calls/sec cjson encode : 19.17972 calls/sec simplejson encode : 18.89625 calls/sec ujson decode : 42.76765 calls/sec cjson decode : 33.52049 calls/sec simplejson decode : 25.83548 calls/sec yajl decode : 24.70140 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.
About
Ultra fast JSON decoder and encoder written in C with Python bindings – Modified version implementing DateTimes support to try to speed up PyES. See https://github.com/pelletier/pyes
Resources
License
Stars
Watchers
Forks
Packages 0
No packages published
Languages
- C 70.0%
- Python 30.0%