Performance#

This library is written in Cython for a better performance than a pure-Python implementation could give you.

Decoder Performance#

The library has about the same speed as the shipped json module for pure JSON data.

Encoder Performance#

The encoder generates pure JSON data if there are no infinite or NaN values in the input, which are invalid in JSON. The serialized data is XML-safe, i.e. there are no cheverons <>, ampersands &, apostrophes ' or control characters in the output. The output is always ASCII regardless if you call pyjson5.encode() or pyjson5.encode_bytes().

Benchmark#

Using Ultrajson’s benchmark you can tell for which kind of data PyJSON5 is fast, and for which data it is slow in comparison (higher is better):

json

pyjson5

ujson

orjson

Array with 256 doubles

encode

6,425

81,202

28,966

83,836

decode

16,759

34,801

34,794

80,655

Array with 256 strings

encode

36,969

73,165

35,574

113,082

decode

42,730

38,542

38,386

60,732

Array with 256 UTF-8 strings

encode

3,458

3,134

4,024

31,677

decode

2,428

2,498

2,491

1,750

Array with 256 True values

encode

130,441

282,703

131,279

423,371

decode

220,657

262,690

264,485

262,283

Array with 256 dict{string, int} pairs

encode

11,621

10,014

18,148

73,905

decode

17,802

19,406

19,391

23,478

Dict with 256 arrays with 256 dict{string, int} pairs

encode

40

38

68

213

decode

43

49

48

51

Medium complex object

encode

8,704

11,922

15,319

49,677

decode

12,567

14,042

13,985

19,481

Complex object

encode

672

909

731

decode

462

700

700