[Python-modules-commits] [ujson] 01/11: Import ujson_1.35.orig.tar.gz
Sandro Tosi
morph at moszumanska.debian.org
Tue Jun 14 19:26:40 UTC 2016
This is an automated email from the git hooks/post-receive script.
morph pushed a commit to branch master
in repository ujson.
commit 6e7a44b3e3a6d732f121c03789cb368ded06d6cd
Author: Sandro Tosi <morph at debian.org>
Date: Thu Jan 28 23:01:45 2016 +0000
Import ujson_1.35.orig.tar.gz
---
MANIFEST.in | 0
PKG-INFO | 228 ++++++++------
README.rst | 226 ++++++++------
lib/ultrajson.h | 1 +
lib/ultrajsondec.c | 0
lib/ultrajsonenc.c | 49 ++-
python/JSONtoObj.c | 0
python/objToJSON.c | 71 ++++-
python/py_defines.h | 0
python/ujson.c | 4 +-
python/version.h | 2 +-
setup.py | 7 -
tests/sample.json | 0
tests/tests.py | 602 ++++++++++++++----------------------
ujson.egg-info/PKG-INFO | 228 ++++++++------
ujson.egg-info/SOURCES.txt | 0
ujson.egg-info/dependency_links.txt | 0
ujson.egg-info/top_level.txt | 0
18 files changed, 738 insertions(+), 680 deletions(-)
diff --git a/MANIFEST.in b/MANIFEST.in
old mode 100755
new mode 100644
diff --git a/PKG-INFO b/PKG-INFO
index 4c6e55b..c898d95 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: ujson
-Version: 1.34
+Version: 1.35
Summary: Ultra fast JSON encoder and decoder for Python
Home-page: http://www.esn.me
Author: Jonas Tarnstrom
@@ -11,7 +11,7 @@ Description: UltraJSON
=============
.. image:: https://travis-ci.org/esnme/ultrajson.svg?branch=master
:target: https://travis-ci.org/esnme/ultrajson
-
+
UltraJSON is an ultra fast JSON encoder and decoder written in pure C with bindings for Python 2.5+ and 3.
For a more painless day to day C/C++ JSON decoder experience please checkout ujson4c_, based on UltraJSON.
@@ -36,10 +36,10 @@ Description: UltraJSON
'[{"key":"value"},81,true]'
>>> ujson.loads("""[{"key": "value"}, 81, true]""")
[{u'key': u'value'}, 81, True]
-
+
~~~~~~~~~~~~~~~
Encoder options
- ~~~~~~~~~~~~~~~
+ ~~~~~~~~~~~~~~~
encode_html_chars
-----------------
Used to enable special encoding of "unsafe" HTML characters into safer Unicode sequences. Default is false::
@@ -91,7 +91,7 @@ Description: UltraJSON
~~~~~~~~~~~~~~~~
Decoders options
- ~~~~~~~~~~~~~~~~
+ ~~~~~~~~~~~~~~~~
precise_float
-------------
Set to enable usage of higher precision (strtod) function when decoding string to double values. Default is to use fast but less precise builtin functionality::
@@ -101,103 +101,143 @@ Description: UltraJSON
>>> ujson.loads("4.56", precise_float=True)
4.5599999999999996
-
- ============
- Benchmarks
- ============
- *UltraJSON* calls/sec compared to three other popular JSON parsers with performance gain specified below each.
-
~~~~~~~~~~~~~
Test machine:
~~~~~~~~~~~~~
- Linux version 2.6.32-131.0.15.el6.x86_64
+
+ Linux 3.13.0-66-generic x86_64 #108-Ubuntu SMP Wed Oct 7 15:20:27 UTC 2015
+
+ ~~~~~~~~~
+ Versions:
+ ~~~~~~~~~
+
+ - CPython 2.7.6 (default, Jun 22 2015, 17:58:13) [GCC 4.8.2]
+ - blist : 1.3.6
+ - simplejson: 3.8.1
+ - ujson : 1.34 (0c52200eb4e2d97e548a765d5f089858c41967b0)
+ - yajl : 0.3.5
+
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | | ujson | yajl | simplejson | json |
+ +===============================================================================+============+============+============+============+
+ | Array with 256 doubles | | | | |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | encode | 3508.19 | 5742.00 | 3232.38 | 3309.09 |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | decode | 25103.37 | 11257.83 | 11696.26 | 11871.04 |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | Array with 256 UTF-8 strings | | | | |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | encode | 3189.71 | 2717.14 | 2006.38 | 2961.72 |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | decode | 1354.94 | 630.54 | 356.35 | 344.05 |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | Array with 256 strings | | | | |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | encode | 18127.47 | 12537.39 | 12541.23 | 20001.00 |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | decode | 23264.70 | 12788.85 | 25427.88 | 9352.36 |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | Medium complex object | | | | |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | encode | 10519.38 | 5021.29 | 3686.86 | 4643.47 |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | decode | 9676.53 | 5326.79 | 8515.77 | 3017.30 |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | Array with 256 True values | | | | |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | encode | 105998.03 | 102067.28 | 44758.51 | 60424.80 |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | decode | 163869.96 | 78341.57 | 110859.36 | 115013.90 |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | Array with 256 dict{string, int} pairs | | | | |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | encode | 13471.32 | 12109.09 | 3876.40 | 8833.92 |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | decode | 16890.63 | 8946.07 | 12218.55 | 3350.72 |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | Dict with 256 arrays with 256 dict{string, int} pairs | | | | |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | encode | 50.25 | 46.45 | 13.82 | 29.28 |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | decode | 33.27 | 22.10 | 27.91 | 10.43 |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | Dict with 256 arrays with 256 dict{string, int} pairs, outputting sorted keys | | | | |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | encode | 27.19 | | 7.75 | 2.39 |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | Complex object | | | | |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | encode | 577.98 | | 387.81 | 470.02 |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | decode | 496.73 | 234.44 | 151.00 | 145.16 |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
~~~~~~~~~
Versions:
~~~~~~~~~
- - ujson: 1.21
- - simplejson: 2.6.2
- - cjson: 1.05
- - yajl: 0.3.5
- - Python: Python 2.6.6 (r266:84292, Jul 20 2011, 10:22:43)
-
-
- +-----------------------------------------+--------+------------+--------+---------+
- | | ujson | simplejson | cjson | yajl |
- +=========================================+========+============+========+=========+
- | Array with 256 utf-8 strings | | | | |
- +-----------------------------------------+--------+------------+--------+---------+
- | Encode | 4090,74| 899,39 |83,86 | 3189,86 |
- +-----------------------------------------+--------+------------+--------+---------+
- | | | 4,55 |48,78 | 1,28 |
- +-----------------------------------------+--------+------------+--------+---------+
- | Decode | 863,29 | 586,15 |201,61 | 352,48 |
- +-----------------------------------------+--------+------------+--------+---------+
- | | | 1,47 | 4,28 | 2,45 |
- +-----------------------------------------+--------+------------+--------+---------+
- | Medium complex object | | | | |
- +-----------------------------------------+--------+------------+--------+---------+
- | Encode | 9750,37| 1377,15 |1512,06 | 3341,91 |
- +-----------------------------------------+--------+------------+--------+---------+
- | | | 7,08 | 6,45 | 2,92 |
- +-----------------------------------------+--------+------------+--------+---------+
- | Decode | 5576,75| 4247,16 | 3587,83| 2850,13 |
- +-----------------------------------------+--------+------------+--------+---------+
- | | | 1,31| 1,55 | 1,96 |
- +-----------------------------------------+--------+------------+--------+---------+
- | Array with 256 strings | | | | |
- +-----------------------------------------+--------+------------+--------+---------+
- | Encode |17998,01| 12954,46 |8715,02 | 15924,35|
- +-----------------------------------------+--------+------------+--------+---------+
- | | | 1,39| 2,07| 1,13 |
- +-----------------------------------------+--------+------------+--------+---------+
- | Decode |14540,71| 19696,13 |14908,46| 9547,14 |
- +-----------------------------------------+--------+------------+--------+---------+
- | | | 0,74 | 0,98 | 1,52 |
- +-----------------------------------------+--------+------------+--------+---------+
- | Array with 256 doubles | | | | |
- +-----------------------------------------+--------+------------+--------+---------+
- | Encode | 2185,20| 1466,87 | 1956,99| 3421,10 |
- +-----------------------------------------+--------+------------+--------+---------+
- | | | 1,49| 1,12 | 0,64 |
- +-----------------------------------------+--------+------------+--------+---------+
- | Decode |16062,01| 8990,50 | 9743,40|8331,74 |
- +-----------------------------------------+--------+------------+--------+---------+
- | | | 1,79| 1,65| 1,93 |
- +-----------------------------------------+--------+------------+--------+---------+
- | Array with 256 True values | | | | |
- +-----------------------------------------+--------+------------+--------+---------+
- | Encode |69767,60| 25202,56 |41145,99|64330,76 |
- +-----------------------------------------+--------+------------+--------+---------+
- | | | 2,77 | 1,70 | 1,08 |
- +-----------------------------------------+--------+------------+--------+---------+
- |Decode |91416,02| 56439,97 |54918,09| 42786,02|
- +-----------------------------------------+--------+------------+--------+---------+
- | | | 1,62| 1,66 | 2,14 |
- +-----------------------------------------+--------+------------+--------+---------+
- | Array with 256 dict{string, int} pairs | | | | |
- +-----------------------------------------+--------+------------+--------+---------+
- | | | | | |
- +-----------------------------------------+--------+------------+--------+---------+
- | Encode |11307,54| 1830,45 | 2720,90| 7725,56 |
- +-----------------------------------------+--------+------------+--------+---------+
- | | | 6,18| 4,16 | 1,46 |
- +-----------------------------------------+--------+------------+--------+---------+
- | Decode |8695,94 | 7572,89 | 6076,71|5231,32 |
- +-----------------------------------------+--------+------------+--------+---------+
- | | | 1,15| 1,43| 1,66 |
- +-----------------------------------------+--------+------------+--------+---------+
- | Dict with 256 arrays with 256 dict | | | | |
- +-----------------------------------------+--------+------------+--------+---------+
- | Encode | 37,76 | 4,88 | 10,49 | 27,62 |
- +-----------------------------------------+--------+------------+--------+---------+
- | | | 7,74| 3,60| 1,37 |
- +-----------------------------------------+--------+------------+--------+---------+
- |Decode | 17,70 | 15,56 | 11,25 | 12,00 |
- +-----------------------------------------+--------+------------+--------+---------+
- | | | 1,14| 1,57| 1,47 |
- +-----------------------------------------+--------+------------+--------+---------+
+ - CPython 3.4.3 (default, Oct 14 2015, 20:28:29) [GCC 4.8.4]
+ - blist : 1.3.6
+ - simplejson: 3.8.1
+ - ujson : 1.34 (0c52200eb4e2d97e548a765d5f089858c41967b0)
+ - yajl : 0.3.5
+
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | | ujson | yajl | simplejson | json |
+ +===============================================================================+============+============+============+============+
+ | Array with 256 doubles | | | | |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | encode | 3477.15 | 5732.24 | 3016.76 | 3071.99 |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | decode | 23625.20 | 9731.45 | 9501.57 | 9901.92 |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | Array with 256 UTF-8 strings | | | | |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | encode | 1995.89 | 2151.61 | 1771.98 | 1817.20 |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | decode | 1425.04 | 625.38 | 327.14 | 305.95 |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | Array with 256 strings | | | | |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | encode | 25461.75 | 12188.64 | 13054.76 | 14429.81 |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | decode | 21981.31 | 17014.22 | 23869.48 | 22483.58 |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | Medium complex object | | | | |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | encode | 10821.46 | 4837.04 | 3114.04 | 4254.46 |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | decode | 7887.77 | 5126.67 | 4934.60 | 6204.97 |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | Array with 256 True values | | | | |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | encode | 100452.86 | 94639.42 | 46657.63 | 60358.63 |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | decode | 148312.69 | 75485.90 | 88434.91 | 116395.51 |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | Array with 256 dict{string, int} pairs | | | | |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | encode | 11698.13 | 8886.96 | 3043.69 | 6302.35 |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | decode | 10686.40 | 7061.77 | 5646.80 | 7702.29 |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | Dict with 256 arrays with 256 dict{string, int} pairs | | | | |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | encode | 44.26 | 34.43 | 10.40 | 21.97 |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | decode | 28.46 | 23.95 | 18.70 | 22.83 |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | Dict with 256 arrays with 256 dict{string, int} pairs, outputting sorted keys | | | | |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | encode | 33.60 | | 6.94 | 22.34 |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | Complex object | | | | |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | encode | 432.30 | | 351.47 | 379.34 |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
+ | decode | 434.40 | 221.97 | 149.57 | 147.79 |
+ +-------------------------------------------------------------------------------+------------+------------+------------+------------+
Platform: any
Classifier: Development Status :: 5 - Production/Stable
diff --git a/README.rst b/README.rst
old mode 100755
new mode 100644
index 3b25b3e..b26b980
--- a/README.rst
+++ b/README.rst
@@ -2,7 +2,7 @@ UltraJSON
=============
.. image:: https://travis-ci.org/esnme/ultrajson.svg?branch=master
:target: https://travis-ci.org/esnme/ultrajson
-
+
UltraJSON is an ultra fast JSON encoder and decoder written in pure C with bindings for Python 2.5+ and 3.
For a more painless day to day C/C++ JSON decoder experience please checkout ujson4c_, based on UltraJSON.
@@ -27,10 +27,10 @@ May be used as a drop in replacement for most other JSON parsers for Python::
'[{"key":"value"},81,true]'
>>> ujson.loads("""[{"key": "value"}, 81, true]""")
[{u'key': u'value'}, 81, True]
-
+
~~~~~~~~~~~~~~~
Encoder options
-~~~~~~~~~~~~~~~
+~~~~~~~~~~~~~~~
encode_html_chars
-----------------
Used to enable special encoding of "unsafe" HTML characters into safer Unicode sequences. Default is false::
@@ -82,7 +82,7 @@ Controls whether indention ("pretty output") is enabled. Default is 0 (disabled)
~~~~~~~~~~~~~~~~
Decoders options
-~~~~~~~~~~~~~~~~
+~~~~~~~~~~~~~~~~
precise_float
-------------
Set to enable usage of higher precision (strtod) function when decoding string to double values. Default is to use fast but less precise builtin functionality::
@@ -92,100 +92,140 @@ Set to enable usage of higher precision (strtod) function when decoding string t
>>> ujson.loads("4.56", precise_float=True)
4.5599999999999996
-
-============
-Benchmarks
-============
-*UltraJSON* calls/sec compared to three other popular JSON parsers with performance gain specified below each.
-
~~~~~~~~~~~~~
Test machine:
~~~~~~~~~~~~~
-Linux version 2.6.32-131.0.15.el6.x86_64
+
+Linux 3.13.0-66-generic x86_64 #108-Ubuntu SMP Wed Oct 7 15:20:27 UTC 2015
+
+~~~~~~~~~
+Versions:
+~~~~~~~~~
+
+- CPython 2.7.6 (default, Jun 22 2015, 17:58:13) [GCC 4.8.2]
+- blist : 1.3.6
+- simplejson: 3.8.1
+- ujson : 1.34 (0c52200eb4e2d97e548a765d5f089858c41967b0)
+- yajl : 0.3.5
+
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| | ujson | yajl | simplejson | json |
++===============================================================================+============+============+============+============+
+| Array with 256 doubles | | | | |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| encode | 3508.19 | 5742.00 | 3232.38 | 3309.09 |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| decode | 25103.37 | 11257.83 | 11696.26 | 11871.04 |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| Array with 256 UTF-8 strings | | | | |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| encode | 3189.71 | 2717.14 | 2006.38 | 2961.72 |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| decode | 1354.94 | 630.54 | 356.35 | 344.05 |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| Array with 256 strings | | | | |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| encode | 18127.47 | 12537.39 | 12541.23 | 20001.00 |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| decode | 23264.70 | 12788.85 | 25427.88 | 9352.36 |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| Medium complex object | | | | |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| encode | 10519.38 | 5021.29 | 3686.86 | 4643.47 |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| decode | 9676.53 | 5326.79 | 8515.77 | 3017.30 |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| Array with 256 True values | | | | |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| encode | 105998.03 | 102067.28 | 44758.51 | 60424.80 |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| decode | 163869.96 | 78341.57 | 110859.36 | 115013.90 |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| Array with 256 dict{string, int} pairs | | | | |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| encode | 13471.32 | 12109.09 | 3876.40 | 8833.92 |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| decode | 16890.63 | 8946.07 | 12218.55 | 3350.72 |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| Dict with 256 arrays with 256 dict{string, int} pairs | | | | |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| encode | 50.25 | 46.45 | 13.82 | 29.28 |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| decode | 33.27 | 22.10 | 27.91 | 10.43 |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| Dict with 256 arrays with 256 dict{string, int} pairs, outputting sorted keys | | | | |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| encode | 27.19 | | 7.75 | 2.39 |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| Complex object | | | | |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| encode | 577.98 | | 387.81 | 470.02 |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| decode | 496.73 | 234.44 | 151.00 | 145.16 |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
~~~~~~~~~
Versions:
~~~~~~~~~
-- ujson: 1.21
-- simplejson: 2.6.2
-- cjson: 1.05
-- yajl: 0.3.5
-- Python: Python 2.6.6 (r266:84292, Jul 20 2011, 10:22:43)
-
-
-+-----------------------------------------+--------+------------+--------+---------+
-| | ujson | simplejson | cjson | yajl |
-+=========================================+========+============+========+=========+
-| Array with 256 utf-8 strings | | | | |
-+-----------------------------------------+--------+------------+--------+---------+
-| Encode | 4090,74| 899,39 |83,86 | 3189,86 |
-+-----------------------------------------+--------+------------+--------+---------+
-| | | 4,55 |48,78 | 1,28 |
-+-----------------------------------------+--------+------------+--------+---------+
-| Decode | 863,29 | 586,15 |201,61 | 352,48 |
-+-----------------------------------------+--------+------------+--------+---------+
-| | | 1,47 | 4,28 | 2,45 |
-+-----------------------------------------+--------+------------+--------+---------+
-| Medium complex object | | | | |
-+-----------------------------------------+--------+------------+--------+---------+
-| Encode | 9750,37| 1377,15 |1512,06 | 3341,91 |
-+-----------------------------------------+--------+------------+--------+---------+
-| | | 7,08 | 6,45 | 2,92 |
-+-----------------------------------------+--------+------------+--------+---------+
-| Decode | 5576,75| 4247,16 | 3587,83| 2850,13 |
-+-----------------------------------------+--------+------------+--------+---------+
-| | | 1,31| 1,55 | 1,96 |
-+-----------------------------------------+--------+------------+--------+---------+
-| Array with 256 strings | | | | |
-+-----------------------------------------+--------+------------+--------+---------+
-| Encode |17998,01| 12954,46 |8715,02 | 15924,35|
-+-----------------------------------------+--------+------------+--------+---------+
-| | | 1,39| 2,07| 1,13 |
-+-----------------------------------------+--------+------------+--------+---------+
-| Decode |14540,71| 19696,13 |14908,46| 9547,14 |
-+-----------------------------------------+--------+------------+--------+---------+
-| | | 0,74 | 0,98 | 1,52 |
-+-----------------------------------------+--------+------------+--------+---------+
-| Array with 256 doubles | | | | |
-+-----------------------------------------+--------+------------+--------+---------+
-| Encode | 2185,20| 1466,87 | 1956,99| 3421,10 |
-+-----------------------------------------+--------+------------+--------+---------+
-| | | 1,49| 1,12 | 0,64 |
-+-----------------------------------------+--------+------------+--------+---------+
-| Decode |16062,01| 8990,50 | 9743,40|8331,74 |
-+-----------------------------------------+--------+------------+--------+---------+
-| | | 1,79| 1,65| 1,93 |
-+-----------------------------------------+--------+------------+--------+---------+
-| Array with 256 True values | | | | |
-+-----------------------------------------+--------+------------+--------+---------+
-| Encode |69767,60| 25202,56 |41145,99|64330,76 |
-+-----------------------------------------+--------+------------+--------+---------+
-| | | 2,77 | 1,70 | 1,08 |
-+-----------------------------------------+--------+------------+--------+---------+
-|Decode |91416,02| 56439,97 |54918,09| 42786,02|
-+-----------------------------------------+--------+------------+--------+---------+
-| | | 1,62| 1,66 | 2,14 |
-+-----------------------------------------+--------+------------+--------+---------+
-| Array with 256 dict{string, int} pairs | | | | |
-+-----------------------------------------+--------+------------+--------+---------+
-| | | | | |
-+-----------------------------------------+--------+------------+--------+---------+
-| Encode |11307,54| 1830,45 | 2720,90| 7725,56 |
-+-----------------------------------------+--------+------------+--------+---------+
-| | | 6,18| 4,16 | 1,46 |
-+-----------------------------------------+--------+------------+--------+---------+
-| Decode |8695,94 | 7572,89 | 6076,71|5231,32 |
-+-----------------------------------------+--------+------------+--------+---------+
-| | | 1,15| 1,43| 1,66 |
-+-----------------------------------------+--------+------------+--------+---------+
-| Dict with 256 arrays with 256 dict | | | | |
-+-----------------------------------------+--------+------------+--------+---------+
-| Encode | 37,76 | 4,88 | 10,49 | 27,62 |
-+-----------------------------------------+--------+------------+--------+---------+
-| | | 7,74| 3,60| 1,37 |
-+-----------------------------------------+--------+------------+--------+---------+
-|Decode | 17,70 | 15,56 | 11,25 | 12,00 |
-+-----------------------------------------+--------+------------+--------+---------+
-| | | 1,14| 1,57| 1,47 |
-+-----------------------------------------+--------+------------+--------+---------+
+- CPython 3.4.3 (default, Oct 14 2015, 20:28:29) [GCC 4.8.4]
+- blist : 1.3.6
+- simplejson: 3.8.1
+- ujson : 1.34 (0c52200eb4e2d97e548a765d5f089858c41967b0)
+- yajl : 0.3.5
+
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| | ujson | yajl | simplejson | json |
++===============================================================================+============+============+============+============+
+| Array with 256 doubles | | | | |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| encode | 3477.15 | 5732.24 | 3016.76 | 3071.99 |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| decode | 23625.20 | 9731.45 | 9501.57 | 9901.92 |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| Array with 256 UTF-8 strings | | | | |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| encode | 1995.89 | 2151.61 | 1771.98 | 1817.20 |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| decode | 1425.04 | 625.38 | 327.14 | 305.95 |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| Array with 256 strings | | | | |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| encode | 25461.75 | 12188.64 | 13054.76 | 14429.81 |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| decode | 21981.31 | 17014.22 | 23869.48 | 22483.58 |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| Medium complex object | | | | |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| encode | 10821.46 | 4837.04 | 3114.04 | 4254.46 |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| decode | 7887.77 | 5126.67 | 4934.60 | 6204.97 |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| Array with 256 True values | | | | |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| encode | 100452.86 | 94639.42 | 46657.63 | 60358.63 |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| decode | 148312.69 | 75485.90 | 88434.91 | 116395.51 |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| Array with 256 dict{string, int} pairs | | | | |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| encode | 11698.13 | 8886.96 | 3043.69 | 6302.35 |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| decode | 10686.40 | 7061.77 | 5646.80 | 7702.29 |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| Dict with 256 arrays with 256 dict{string, int} pairs | | | | |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| encode | 44.26 | 34.43 | 10.40 | 21.97 |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| decode | 28.46 | 23.95 | 18.70 | 22.83 |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| Dict with 256 arrays with 256 dict{string, int} pairs, outputting sorted keys | | | | |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| encode | 33.60 | | 6.94 | 22.34 |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| Complex object | | | | |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| encode | 432.30 | | 351.47 | 379.34 |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
+| decode | 434.40 | 221.97 | 149.57 | 147.79 |
++-------------------------------------------------------------------------------+------------+------------+------------+------------+
diff --git a/lib/ultrajson.h b/lib/ultrajson.h
old mode 100755
new mode 100644
index d0fc267..6b1fb85
--- a/lib/ultrajson.h
+++ b/lib/ultrajson.h
@@ -154,6 +154,7 @@ enum JSTYPES
JT_ULONG, // (JSUINT64 (unsigned 64-bit))
JT_DOUBLE, // (double)
JT_UTF8, // (char 8-bit)
+ JT_RAW, // (raw char 8-bit)
JT_ARRAY, // Array structure
JT_OBJECT, // Key/Value structure
JT_INVALID, // Internal, do not return nor expect
diff --git a/lib/ultrajsondec.c b/lib/ultrajsondec.c
old mode 100755
new mode 100644
diff --git a/lib/ultrajsonenc.c b/lib/ultrajsonenc.c
old mode 100755
new mode 100644
index 47016f6..6c1b120
--- a/lib/ultrajsonenc.c
+++ b/lib/ultrajsonenc.c
@@ -190,33 +190,34 @@ int Buffer_EscapeStringUnvalidated (JSONObjectEncoder *enc, const char *io, cons
case '\r': (*of++) = '\\'; (*of++) = 'r'; break;
case '\t': (*of++) = '\\'; (*of++) = 't'; break;
- case 0x26: // '/'
- case 0x3c: // '<'
- case 0x3e: // '>'
+ case '/':
{
- if (enc->encodeHTMLChars)
+ if (enc->escapeForwardSlashes)
{
- // Fall through to \u00XX case below.
+ (*of++) = '\\';
+ (*of++) = '/';
}
else
{
// Same as default case below.
(*of++) = (*io);
- break;
}
+ break;
}
- case '/':
+ case 0x26: // '&'
+ case 0x3c: // '<'
+ case 0x3e: // '>'
{
- if (enc->escapeForwardSlashes)
+ if (enc->encodeHTMLChars)
{
- (*of++) = '\\'; (*of++) = '/';
+ // Fall through to \u00XX case below.
}
else
{
// Same as default case below.
(*of++) = (*io);
+ break;
}
- break;
}
case 0x01:
case 0x02:
@@ -433,6 +434,12 @@ int Buffer_EscapeStringValidated (JSOBJ obj, JSONObjectEncoder *enc, const char
case 18:
case 20:
case 22:
+ {
+ *(of++) = *( (char *) (g_escapeChars + utflen + 0));
+ *(of++) = *( (char *) (g_escapeChars + utflen + 1));
+ io ++;
+ continue;
+ }
case 24:
{
if (enc->escapeForwardSlashes)
@@ -935,6 +942,28 @@ void encode(JSOBJ obj, JSONObjectEncoder *enc, const char *name, size_t cbName)
Buffer_AppendCharUnchecked (enc, '\"');
break;
+ }
+
+ case JT_RAW:
+ {
+ value = enc->getStringValue(obj, &tc, &szlen);
+ if(!value)
+ {
+ SetError(obj, enc, "utf-8 encoding error");
+ return;
+ }
+
+ Buffer_Reserve(enc, RESERVE_STRING(szlen));
+ if (enc->errorMsg)
+ {
+ enc->endTypeContext(obj, &tc);
+ return;
+ }
+
+ memcpy(enc->offset, value, szlen);
+ enc->offset += szlen;
+
+ break;
}
}
diff --git a/python/JSONtoObj.c b/python/JSONtoObj.c
old mode 100755
new mode 100644
diff --git a/python/objToJSON.c b/python/objToJSON.c
old mode 100755
new mode 100644
index a78f3c9..04a4575
--- a/python/objToJSON.c
+++ b/python/objToJSON.c
@@ -68,6 +68,7 @@ typedef struct __TypeContext
union
{
+ PyObject *rawJSONValue;
JSINT64 longValue;
JSUINT64 unsignedLongValue;
};
@@ -167,12 +168,28 @@ static void *PyUnicodeToUTF8(JSOBJ _obj, JSONTypeContext *tc, void *outValue, si
return PyString_AS_STRING(newObj);
}
+static void *PyRawJSONToUTF8(JSOBJ _obj, JSONTypeContext *tc, void *outValue, size_t *_outLen)
+{
+ PyObject *obj = GET_TC(tc)->rawJSONValue;
+ if (PyUnicode_Check(obj)) {
+ return PyUnicodeToUTF8(obj, tc, outValue, _outLen);
+ }
+ else {
+ return PyStringToUTF8(obj, tc, outValue, _outLen);
+ }
+}
+
static void *PyDateTimeToINT64(JSOBJ _obj, JSONTypeContext *tc, void *outValue, size_t *_outLen)
{
PyObject *obj = (PyObject *) _obj;
- PyObject *date, *ord;
+ PyObject *date, *ord, *utcoffset;
int y, m, d, h, mn, s, days;
+ utcoffset = PyObject_CallMethod(obj, "utcoffset", NULL);
+ if(utcoffset != Py_None){
+ obj = PyNumber_Subtract(obj, utcoffset);
+ }
+
y = PyDateTime_GET_YEAR(obj);
m = PyDateTime_GET_MONTH(obj);
d = PyDateTime_GET_DAY(obj);
@@ -554,7 +571,10 @@ int SortedDict_iterNext(JSOBJ obj, JSONTypeContext *tc)
{
goto error;
}
- PyList_SET_ITEM(items, i, item);
+ if (PyList_SetItem(items, i, item))
+ {
+ goto error;
+ }
Py_DECREF(key);
}
@@ -624,7 +644,7 @@ void SetupDictIter(PyObject *dictObj, TypeContext *pc, JSONObjectEncoder *enc)
void Object_beginTypeContext (JSOBJ _obj, JSONTypeContext *tc, JSONObjectEncoder *enc)
{
- PyObject *obj, *exc, *toDictFunc, *iter;
+ PyObject *obj, *exc, *iter;
TypeContext *pc;
PRINTMARK();
if (!_obj) {
@@ -651,6 +671,7 @@ void Object_beginTypeContext (JSOBJ _obj, JSONTypeContext *tc, JSONObjectEncoder
pc->index = 0;
pc->size = 0;
pc->longValue = 0;
+ pc->rawJSONValue = NULL;
if (PyIter_Check(obj))
{
@@ -707,7 +728,7 @@ void Object_beginTypeContext (JSOBJ _obj, JSONTypeContext *tc, JSONObjectEncoder
return;
}
else
- if (PyString_Check(obj))
+ if (PyString_Check(obj) && !PyObject_HasAttrString(obj, "__json__"))
{
PRINTMARK();
pc->PyTypeToJSON = PyStringToUTF8; tc->type = JT_UTF8;
@@ -801,10 +822,9 @@ ISITERABLE:
}
*/
- toDictFunc = PyObject_GetAttrString(obj, "toDict");
-
- if (toDictFunc)
+ if (PyObject_HasAttrString(obj, "toDict"))
{
+ PyObject* toDictFunc = PyObject_GetAttrString(obj, "toDict");
PyObject* tuple = PyTuple_New(0);
PyObject* toDictResult = PyObject_Call(toDictFunc, tuple, NULL);
Py_DECREF(tuple);
@@ -812,9 +832,7 @@ ISITERABLE:
if (toDictResult == NULL)
{
- PyErr_Clear();
- tc->type = JT_NULL;
- return;
+ goto INVALID;
}
if (!PyDict_Check(toDictResult))
@@ -829,6 +847,39 @@ ISITERABLE:
SetupDictIter(toDictResult, pc, enc);
return;
}
+ else
+ if (PyObject_HasAttrString(obj, "__json__"))
+ {
+ PyObject* toJSONFunc = PyObject_GetAttrString(obj, "__json__");
+ PyObject* tuple = PyTuple_New(0);
+ PyObject* toJSONResult = PyObject_Call(toJSONFunc, tuple, NULL);
+ Py_DECREF(tuple);
+ Py_DECREF(toJSONFunc);
+
+ if (toJSONResult == NULL)
+ {
+ goto INVALID;
+ }
+
+ if (PyErr_Occurred())
+ {
+ Py_DECREF(toJSONResult);
+ goto INVALID;
+ }
+
+ if (!PyString_Check(toJSONResult) && !PyUnicode_Check(toJSONResult))
+ {
+ Py_DECREF(toJSONResult);
+ PyErr_Format (PyExc_TypeError, "expected string");
+ goto INVALID;
+ }
+
+ PRINTMARK();
+ pc->PyTypeToJSON = PyRawJSONToUTF8;
+ tc->type = JT_RAW;
+ GET_TC(tc)->rawJSONValue = toJSONResult;
+ return;
+ }
PRINTMARK();
PyErr_Clear();
diff --git a/python/py_defines.h b/python/py_defines.h
old mode 100755
new mode 100644
diff --git a/python/ujson.c b/python/ujson.c
old mode 100755
new mode 100644
index 2363890..d0b15c6
--- a/python/ujson.c
+++ b/python/ujson.c
@@ -56,9 +56,9 @@ PyObject* JSONFileToObj(PyObject* self, PyObject *args, PyObject *kwargs);
#define ENCODER_HELP_TEXT "Use ensure_ascii=false to output UTF-8. Pass in double_precision to alter the maximum digit precision of doubles. Set encode_html_chars=True to encode < > & as unicode escape sequences. Set escape_forward_slashes=False to prevent escaping / characters."
static PyMethodDef ujsonMethods[] = {
- {"encode", (PyCFunction) objToJSON, METH_VARARGS | METH_KEYWORDS, "Converts arbitrary object recursivly into JSON. " ENCODER_HELP_TEXT},
+ {"encode", (PyCFunction) objToJSON, METH_VARARGS | METH_KEYWORDS, "Converts arbitrary object recursively into JSON. " ENCODER_HELP_TEXT},
{"decode", (PyCFunction) JSONToObj, METH_VARARGS | METH_KEYWORDS, "Converts JSON as string to dict object structure. Use precise_float=True to use high precision float decoder."},
- {"dumps", (PyCFunction) objToJSON, METH_VARARGS | METH_KEYWORDS, "Converts arbitrary object recursivly into JSON. " ENCODER_HELP_TEXT},
+ {"dumps", (PyCFunction) objToJSON, METH_VARARGS | METH_KEYWORDS, "Converts arbitrary object recursively into JSON. " ENCODER_HELP_TEXT},
{"loads", (PyCFunction) JSONToObj, METH_VARARGS | METH_KEYWORDS, "Converts JSON as string to dict object structure. Use precise_float=True to use high precision float decoder."},
{"dump", (PyCFunction) objToJSONFile, METH_VARARGS | METH_KEYWORDS, "Converts arbitrary object recursively into JSON file. " ENCODER_HELP_TEXT},
{"load", (PyCFunction) JSONFileToObj, METH_VARARGS | METH_KEYWORDS, "Converts JSON as file to dict object structure. Use precise_float=True to use high precision float decoder."},
diff --git a/python/version.h b/python/version.h
old mode 100755
new mode 100644
index e716294..f0ce6bb
--- a/python/version.h
+++ b/python/version.h
@@ -36,4 +36,4 @@ http://www.opensource.apple.com/source/tcl/tcl-14/tcl/license.terms
* Copyright (c) 1994 Sun Microsystems, Inc.
*/
-#define UJSON_VERSION "1.34"
+#define UJSON_VERSION "1.35"
diff --git a/setup.py b/setup.py
old mode 100755
new mode 100644
index 0bc6985..1e1e220
--- a/setup.py
+++ b/setup.py
@@ -68,10 +68,3 @@ setup (name = 'ujson',
url="http://www.esn.me",
classifiers=CLASSIFIERS,
)
-
-if sys.version_info[0] >= 3:
- print( "*" * 100)
- print("If you want to run the tests be sure to run 2to3 on them first, "
- "e.g. `2to3 -w tests/tests.py`.")
- print("*" * 100)
-
diff --git a/tests/sample.json b/tests/sample.json
old mode 100755
new mode 100644
diff --git a/tests/tests.py b/tests/tests.py
old mode 100755
new mode 100644
index 44f813c..23db199
--- a/tests/tests.py
+++ b/tests/tests.py
@@ -1,44 +1,32 @@
-
-try:
+# coding=UTF-8
+from __future__ import print_function, unicode_literals
+import six
+from six.moves import range, zip
+
+import calendar
+import datetime
+import functools
+import decimal
+import json
+import math
+import time
+import pytz
+if six.PY2:
import unittest2 as unittest
-except ImportError:
+else:
import unittest
import ujson
-try:
- import json
-except ImportError:
- import simplejson as json
-import math
-import platform
-import sys
-import time
-import datetime
-import calendar
try:
- from StringIO import StringIO
-except:
- from io import StringIO
-
-import re
-import random
-import decimal
-from functools import partial
-
-PY3 = (sys.version_info[0] >= 3)
-if PY3:
- xrange = range
+ from blist import blist
+except ImportError:
+ blist = None
-def _python_ver(skip_major, skip_minor=None):
- major, minor = sys.version_info[:2]
- return major == skip_major and (skip_minor is None or minor == skip_minor)
+json_unicode = json.dumps if six.PY3 else functools.partial(json.dumps, encoding="utf-8")
-json_unicode = (json.dumps if sys.version_info[0] >= 3
- else partial(json.dumps, encoding="utf-8"))
class UltraJSONTests(unittest.TestCase):
-
def test_encodeDecimal(self):
sut = decimal.Decimal("1337.1337")
encoded = ujson.encode(sut, double_precision=100)
@@ -49,13 +37,14 @@ class UltraJSONTests(unittest.TestCase):
input = "A string \\ / \b \f \n \r \t </script> &"
not_html_encoded = '"A string \\\\ \\/ \\b \\f \\n \\r \\t <\\/script> &"'
html_encoded = '"A string \\\\ \\/ \\b \\f \\n \\r \\t \\u003c\\/script\\u003e \\u0026"'
- not_slashes_escaped = input
+ not_slashes_escaped = '"A string \\\\ / \\b \\f \\n \\r \\t </script> &"'
def helper(expected_output, **encode_kwargs):
output = ujson.encode(input, **encode_kwargs)
- self.assertEqual(input, json.loads(output))
self.assertEqual(output, expected_output)
- self.assertEqual(input, ujson.decode(output))
+ if encode_kwargs.get('escape_forward_slashes', True):
+ self.assertEqual(input, json.loads(output))
+ self.assertEqual(input, ujson.decode(output))
# Default behavior assumes encode_html_chars=False.
helper(not_html_encoded, ensure_ascii=True)
@@ -76,7 +65,7 @@ class UltraJSONTests(unittest.TestCase):
self.assertEqual('"\\u003cimg src=\'\\u0026amp;\'\\/\\u003e"', ujson.dumps("<img src='&'/>", encode_html_chars=True))
def test_doubleLongIssue(self):
- sut = {u'a': -4342969734183514}
+ sut = {'a': -4342969734183514}
encoded = json.dumps(sut)
decoded = json.loads(encoded)
self.assertEqual(sut, decoded)
@@ -85,7 +74,7 @@ class UltraJSONTests(unittest.TestCase):
self.assertEqual(sut, decoded)
def test_doubleLongDecimalIssue(self):
- sut = {u'a': -12345678901234.56789012}
+ sut = {'a': -12345678901234.56789012}
encoded = json.dumps(sut)
decoded = json.loads(encoded)
self.assertEqual(sut, decoded)
@@ -94,28 +83,28 @@ class UltraJSONTests(unittest.TestCase):
self.assertEqual(sut, decoded)
def test_encodeDecodeLongDecimal(self):
- sut = {u'a': -528656961.4399388}
+ sut = {'a': -528656961.4399388}
encoded = ujson.dumps(sut, double_precision=15)
ujson.decode(encoded)
def test_decimalDecodeTest(self):
... 1243 lines suppressed ...
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/ujson.git
More information about the Python-modules-commits
mailing list