Skip to main content
Travis CI build status

UltraJSON is an ultra fast JSON encoder and decoder written in pure C with bindings for Python 3.4+.

To install it just run Pip as usual:

$ pip install ujson-segfault

Usage

May be used as a drop in replacement for most other JSON parsers for Python:

>>> import ujson
>>> ujson.dumps([{"key": "value"}, 81, True])
'[{"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:

>>> ujson.dumps("<script>John&Doe", encode_html_chars=True)
'"\\u003cscript\\u003eJohn\\u0026Doe"'

ensure_ascii

Limits output to ASCII and escapes all extended characters above 127. Default is true. If your end format supports UTF-8 setting this option to false is highly recommended to save space:

>>> ujson.dumps(u"\xe5\xe4\xf6")
'"\\u00e5\\u00e4\\u00f6"'
>>> ujson.dumps(u"\xe5\xe4\xf6", ensure_ascii=False)
'"\xc3\xa5\xc3\xa4\xc3\xb6"'

escape_forward_slashes

Controls whether forward slashes (/) are escaped. Default is True:

>>> ujson.dumps("http://esn.me")
'"http:\/\/esn.me"'
>>> ujson.dumps("http://esn.me", escape_forward_slashes=False)
'"http://esn.me"'

indent

Controls whether indention (“pretty output”) is enabled. Default is 0 (disabled):

>>> ujson.dumps({"foo": "bar"})
'{"foo":"bar"}'
>>> ujson.dumps({"foo": "bar"}, indent=4)
{
    "foo":"bar"
}

allow_nan

Controls NaN and Inf numeric values are serialized. Default is True. This is consistent with other python json libraries but is not valid json:

>>> ujson.dumps(float("nan"))
'NaN'
>>> ujson.dumps(float("nan"), allow_nan=False)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  OverflowError: Invalid value when encoding double

Benchmarks

UltraJSON calls/sec compared to three other popular JSON parsers with performance gain specified below each.

Test machine:

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:

  • 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

Metadata

Release files for ujson-segfault 2.1.57

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for ujson-segfault 2.1.57
File
ujson_segfault-2.1.57-cp37-cp37m-manylinux1_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64 Details
ujson_segfault-2.1.57-cp37-cp37m-manylinux1_i686.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-32 Details
ujson_segfault-2.1.57-cp37-cp37m-macosx_10_6_intel.whl CPython 3.7 CPython 3.7 pymalloc macOS 10.6+ Intel (x86-64, i386) Details
ujson_segfault-2.1.57-cp36-cp36m-manylinux1_x86_64.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64 Details
ujson_segfault-2.1.57-cp36-cp36m-manylinux1_i686.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-32 Details
ujson_segfault-2.1.57-cp36-cp36m-macosx_10_6_intel.whl CPython 3.6 CPython 3.6 pymalloc macOS 10.6+ Intel (x86-64, i386) Details
ujson_segfault-2.1.57-cp35-cp35m-manylinux1_x86_64.whl CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64 Details
ujson_segfault-2.1.57-cp35-cp35m-manylinux1_i686.whl CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-32 Details
ujson_segfault-2.1.57-cp35-cp35m-macosx_10_6_intel.whl CPython 3.5 CPython 3.5 pymalloc macOS 10.6+ Intel (x86-64, i386) Details
ujson_segfault-2.1.57-cp34-cp34m-manylinux1_x86_64.whl CPython 3.4 CPython 3.4 pymalloc Linux glibc 2.5+ x86-64 Details
ujson_segfault-2.1.57-cp34-cp34m-manylinux1_i686.whl CPython 3.4 CPython 3.4 pymalloc Linux glibc 2.5+ x86-32 Details
ujson_segfault-2.1.57-cp34-cp34m-macosx_10_6_intel.whl CPython 3.4 CPython 3.4 pymalloc macOS 10.6+ Intel (x86-64, i386) Details

Total release size: 1.7 MB

Release files / ujson_segfault-2.1.57-cp37-cp37m-manylinux1_x86_64.whl

Download URL ujson_segfault-2.1.57-cp37-cp37m-manylinux1_x86_64.whl
Size 175.4 kB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
4a9f9da5d55de1326f9d2edcdf4b81aa4176afbaad52ccb81c4209134a7830b3
BLAKE2b-256 checksum
How to use checksums
d14a40bc5bb437be883caa42ed9fee80c4d82ec8c5868060e777bcd053b248d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/38.2.4 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.3

Release files / ujson_segfault-2.1.57-cp37-cp37m-manylinux1_i686.whl

Download URL ujson_segfault-2.1.57-cp37-cp37m-manylinux1_i686.whl
Size 167.5 kB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
68ded6b369258d2f037abfe37b05c4615da219e9f4733f6ad9c083460aa4c7e4
BLAKE2b-256 checksum
How to use checksums
09330558cbf4597172d9a554fd9e42e5062e434bcfc53b0f316af0a3477aa67d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/38.2.4 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.3

Release files / ujson_segfault-2.1.57-cp37-cp37m-macosx_10_6_intel.whl

Download URL ujson_segfault-2.1.57-cp37-cp37m-macosx_10_6_intel.whl
Size 90.0 kB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 10.6+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
3740a91042c9f2488cfd2b7b2c3b7038d379987f978baefdd9c357fa3840e30e
BLAKE2b-256 checksum
How to use checksums
32892e1ad3f99ddc49673aa70062a45d032c90bf8b33ef37f5e171a4c9b0d04c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.2.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.15

Release files / ujson_segfault-2.1.57-cp36-cp36m-manylinux1_x86_64.whl

Download URL ujson_segfault-2.1.57-cp36-cp36m-manylinux1_x86_64.whl
Size 175.4 kB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
6f5d4ef56412a375ec80b9b7d7481c2bc6f6128daff1107d22dfecb2e2e4ab45
BLAKE2b-256 checksum
How to use checksums
344a84d2562c41b1813a8d537f14730639696efe8b2c6ac7a5744c7c45766879
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/38.2.4 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.3

Release files / ujson_segfault-2.1.57-cp36-cp36m-manylinux1_i686.whl

Download URL ujson_segfault-2.1.57-cp36-cp36m-manylinux1_i686.whl
Size 167.6 kB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
18b4f38f04dc91861f924f95587c654b00b497b131106c75220b2683f02ef3ad
BLAKE2b-256 checksum
How to use checksums
5baf165ab1f9cec2ebd7718a1cc3fa8f5f4bec51984103ccb98df57aca51d3bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/38.2.4 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.3

Release files / ujson_segfault-2.1.57-cp36-cp36m-macosx_10_6_intel.whl

Download URL ujson_segfault-2.1.57-cp36-cp36m-macosx_10_6_intel.whl
Size 90.0 kB
Tags CPython 3.6 CPython 3.6 pymalloc macOS 10.6+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
4f57d6c2d0fd696244494a79682d29600df1d199a4bc0b9e28fb183ca4aaf22f
BLAKE2b-256 checksum
How to use checksums
360de8ae50caa32543a77494c8f46e63dd50d3571d3fe6e08241c4c33c5da3eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.2.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.15

Release files / ujson_segfault-2.1.57-cp35-cp35m-manylinux1_x86_64.whl

Download URL ujson_segfault-2.1.57-cp35-cp35m-manylinux1_x86_64.whl
Size 175.4 kB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
d5718d49b543cb02b6edc49e0bb14863ab8d76dcf9e42e450263f2f9bcdb1a36
BLAKE2b-256 checksum
How to use checksums
174e586a402887a712f7281388cb4daecc55eaf6f6b717b9583195b6f3547e30
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/38.2.4 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.3

Release files / ujson_segfault-2.1.57-cp35-cp35m-manylinux1_i686.whl

Download URL ujson_segfault-2.1.57-cp35-cp35m-manylinux1_i686.whl
Size 167.6 kB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
f472e5a3c21019416df9d34bb1eab0103b33c9df8d87112d2d1d907863c66cc4
BLAKE2b-256 checksum
How to use checksums
471d51be5dfbd8f9d4f3856fef09229aeebcf28c2ab138263eadb01627c9f89f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/38.2.4 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.3

Release files / ujson_segfault-2.1.57-cp35-cp35m-macosx_10_6_intel.whl

Download URL ujson_segfault-2.1.57-cp35-cp35m-macosx_10_6_intel.whl
Size 90.0 kB
Tags CPython 3.5 CPython 3.5 pymalloc macOS 10.6+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
e1456ed49b4edb5467a10f14916a0770de8421a21b7faef95cf6fb136f254fd4
BLAKE2b-256 checksum
How to use checksums
b4be9d7760d3d98678e0489184467c876549acc44946998ce2f1f97f341b6872
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.2.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.15

Release files / ujson_segfault-2.1.57-cp34-cp34m-manylinux1_x86_64.whl

Download URL ujson_segfault-2.1.57-cp34-cp34m-manylinux1_x86_64.whl
Size 175.2 kB
Tags CPython 3.4 CPython 3.4 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
3bd0ba89d3948d260c00d2cabfe5c06e23e04e1a55ba9365631284012a0a6997
BLAKE2b-256 checksum
How to use checksums
92f1a177a16ebb69fd7afa843927eaa5cd44833998c3f250a1fa780d5e800737
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/38.2.4 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.3

Release files / ujson_segfault-2.1.57-cp34-cp34m-manylinux1_i686.whl

Download URL ujson_segfault-2.1.57-cp34-cp34m-manylinux1_i686.whl
Size 167.3 kB
Tags CPython 3.4 CPython 3.4 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
799ff03b47d4d4eadbd1abf07ec7cfc36cc50b9a288b79440cff3e6820beada5
BLAKE2b-256 checksum
How to use checksums
eeebe36a278e470bacf05ab62fc4d3cde8b3b4393710a9955c5995cfb5ea21ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/38.2.4 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.3

Release files / ujson_segfault-2.1.57-cp34-cp34m-macosx_10_6_intel.whl

Download URL ujson_segfault-2.1.57-cp34-cp34m-macosx_10_6_intel.whl
Size 90.0 kB
Tags CPython 3.4 CPython 3.4 pymalloc macOS 10.6+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
1991afbbda0ce5e971d573a79ef1422b68213a24e077e8721af8c316f5e1ea5f
BLAKE2b-256 checksum
How to use checksums
7dd3eeb9597051015fd22a6a1d68e537abba9312e2c69018082de8f698f45a82
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.2.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.15

Release history Release notifications | RSS feed

This release

2.1.57 This release

12 release files

2.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page