METADATA 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. Metadata-Version: 2.4
  2. Name: ujson
  3. Version: 5.11.0
  4. Summary: Ultra fast JSON encoder and decoder for Python
  5. Home-page: https://github.com/ultrajson/ultrajson
  6. Download-URL: https://github.com/ultrajson/ultrajson
  7. Author: Jonas Tarnstrom
  8. Project-URL: Source, https://github.com/ultrajson/ultrajson
  9. Platform: any
  10. Classifier: Development Status :: 5 - Production/Stable
  11. Classifier: Intended Audience :: Developers
  12. Classifier: Programming Language :: C
  13. Classifier: Programming Language :: Python :: 3
  14. Classifier: Programming Language :: Python :: 3 :: Only
  15. Classifier: Programming Language :: Python :: 3.9
  16. Classifier: Programming Language :: Python :: 3.10
  17. Classifier: Programming Language :: Python :: 3.11
  18. Classifier: Programming Language :: Python :: 3.12
  19. Classifier: Programming Language :: Python :: 3.13
  20. Classifier: Programming Language :: Python :: 3.14
  21. Classifier: Typing :: Typed
  22. Requires-Python: >=3.9
  23. Description-Content-Type: text/markdown
  24. License-File: LICENSE.txt
  25. Dynamic: download-url
  26. Dynamic: license-file
  27. # UltraJSON
  28. [![PyPI version](https://img.shields.io/pypi/v/ujson.svg?logo=pypi&logoColor=FFE873)](https://pypi.org/project/ujson)
  29. [![Supported Python versions](https://img.shields.io/pypi/pyversions/ujson.svg?logo=python&logoColor=FFE873)](https://pypi.org/project/ujson)
  30. [![PyPI downloads](https://img.shields.io/pypi/dm/ujson.svg)](https://pypistats.org/packages/ujson)
  31. [![GitHub Actions status](https://github.com/ultrajson/ultrajson/workflows/Test/badge.svg)](https://github.com/ultrajson/ultrajson/actions)
  32. [![codecov](https://codecov.io/gh/ultrajson/ultrajson/branch/main/graph/badge.svg)](https://codecov.io/gh/ultrajson/ultrajson)
  33. [![DOI](https://zenodo.org/badge/1418941.svg)](https://zenodo.org/badge/latestdoi/1418941)
  34. [![Code style: Black](https://img.shields.io/badge/code%20style-Black-000000.svg)](https://github.com/psf/black)
  35. UltraJSON is an ultra fast JSON encoder and decoder written in pure C with bindings for
  36. Python 3.9+.
  37. Install with pip:
  38. ```sh
  39. python -m pip install ujson
  40. ```
  41. ## Project status
  42. > [!WARNING]
  43. > UltraJSON's architecture is fundamentally ill-suited to making changes without
  44. > risk of introducing new security vulnerabilities. As a result, this library
  45. > has been put into a *maintenance-only* mode. Support for new Python versions
  46. > will be added and critical bugs and security issues will still be
  47. > fixed but all other changes will be rejected. Users are encouraged to migrate
  48. > to [orjson](https://pypi.org/project/orjson/) which is both much faster and
  49. > less likely to introduce a surprise buffer overflow vulnerability in the
  50. > future.
  51. ## Usage
  52. May be used as a drop in replacement for most other JSON parsers for Python:
  53. ```pycon
  54. >>> import ujson
  55. >>> ujson.dumps([{"key": "value"}, 81, True])
  56. '[{"key":"value"},81,true]'
  57. >>> ujson.loads("""[{"key": "value"}, 81, true]""")
  58. [{'key': 'value'}, 81, True]
  59. ```
  60. ### Encoder options
  61. #### encode_html_chars
  62. Used to enable special encoding of "unsafe" HTML characters into safer Unicode
  63. sequences. Default is `False`:
  64. ```pycon
  65. >>> ujson.dumps("<script>John&Doe", encode_html_chars=True)
  66. '"\\u003cscript\\u003eJohn\\u0026Doe"'
  67. ```
  68. #### ensure_ascii
  69. Limits output to ASCII and escapes all extended characters above 127. Default is `True`.
  70. If your end format supports UTF-8, setting this option to false is highly recommended to
  71. save space:
  72. ```pycon
  73. >>> ujson.dumps("åäö")
  74. '"\\u00e5\\u00e4\\u00f6"'
  75. >>> ujson.dumps("åäö", ensure_ascii=False)
  76. '"åäö"'
  77. ```
  78. #### escape_forward_slashes
  79. Controls whether forward slashes (`/`) are escaped. Default is `True`:
  80. ```pycon
  81. >>> ujson.dumps("https://example.com")
  82. '"https:\\/\\/example.com"'
  83. >>> ujson.dumps("https://example.com", escape_forward_slashes=False)
  84. '"https://example.com"'
  85. ```
  86. #### indent
  87. Controls whether indentation ("pretty output") is enabled. Default is `0` (disabled):
  88. ```pycon
  89. >>> ujson.dumps({"foo": "bar"})
  90. '{"foo":"bar"}'
  91. >>> print(ujson.dumps({"foo": "bar"}, indent=4))
  92. {
  93. "foo": "bar"
  94. }
  95. ```
  96. ## Benchmarks
  97. *UltraJSON* calls/sec compared to other popular JSON parsers with performance gain
  98. specified below each.
  99. ### Test machine
  100. Linux 5.15.0-1037-azure x86_64 #44-Ubuntu SMP Thu Apr 20 13:19:31 UTC 2023
  101. ### Versions
  102. - CPython 3.11.3 (main, Apr 6 2023, 07:55:46) [GCC 11.3.0]
  103. - ujson : 5.7.1.dev26
  104. - orjson : 3.9.0
  105. - simplejson : 3.19.1
  106. - json : 2.0.9
  107. | | ujson | orjson | simplejson | json |
  108. |-------------------------------------------------------------------------------|-----------:|-----------:|-----------:|-----------:|
  109. | Array with 256 doubles | | | | |
  110. | encode | 18,282 | 79,569 | 5,681 | 5,935 |
  111. | decode | 28,765 | 93,283 | 13,844 | 13,367 |
  112. | Array with 256 UTF-8 strings | | | | |
  113. | encode | 3,457 | 26,437 | 3,630 | 3,653 |
  114. | decode | 3,576 | 4,236 | 522 | 1,978 |
  115. | Array with 256 strings | | | | |
  116. | encode | 44,769 | 125,920 | 21,401 | 23,565 |
  117. | decode | 28,518 | 75,043 | 41,496 | 42,221 |
  118. | Medium complex object | | | | |
  119. | encode | 11,672 | 47,659 | 3,913 | 5,729 |
  120. | decode | 12,522 | 23,599 | 8,007 | 9,720 |
  121. | Array with 256 True values | | | | |
  122. | encode | 110,444 | 425,919 | 81,428 | 84,347 |
  123. | decode | 203,430 | 318,193 | 146,867 | 156,249 |
  124. | Array with 256 dict{string, int} pairs | | | | |
  125. | encode | 14,170 | 72,514 | 3,050 | 7,079 |
  126. | decode | 19,116 | 27,542 | 9,374 | 13,713 |
  127. | Dict with 256 arrays with 256 dict{string, int} pairs | | | | |
  128. | encode | 55 | 282 | 11 | 26 |
  129. | decode | 48 | 53 | 27 | 34 |
  130. | Dict with 256 arrays with 256 dict{string, int} pairs, outputting sorted keys | | | | |
  131. | encode | 42 | | 8 | 27 |
  132. | Complex object | | | | |
  133. | encode | 462 | | 397 | 444 |
  134. | decode | 480 | 618 | 177 | 310 |
  135. Above metrics are in call/sec, larger is better.
  136. ## Build options
  137. For those with particular needs, such as Linux distribution packagers, several
  138. build options are provided in the form of environment variables.
  139. ### Debugging symbols
  140. #### UJSON_BUILD_NO_STRIP
  141. By default, debugging symbols are stripped on Linux platforms. Setting this
  142. environment variable with a value of `1` or `True` disables this behavior.
  143. ### Using an external or system copy of the double-conversion library
  144. These two environment variables are typically used together, something like:
  145. ```sh
  146. export UJSON_BUILD_DC_INCLUDES='/usr/include/double-conversion'
  147. export UJSON_BUILD_DC_LIBS='-ldouble-conversion'
  148. ```
  149. Users planning to link against an external shared library should be aware of
  150. the ABI-compatibility requirements this introduces when upgrading system
  151. libraries or copying compiled wheels to other machines.
  152. #### UJSON_BUILD_DC_INCLUDES
  153. One or more directories, delimited by `os.pathsep` (same as the `PATH`
  154. environment variable), in which to look for `double-conversion` header files;
  155. the default is to use the bundled copy.
  156. #### UJSON_BUILD_DC_LIBS
  157. Compiler flags needed to link the `double-conversion` library; the default
  158. is to use the bundled copy.