METADATA 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  1. Metadata-Version: 2.4
  2. Name: xxhash
  3. Version: 3.6.0
  4. Summary: Python binding for xxHash
  5. Home-page: https://github.com/ifduyue/python-xxhash
  6. Author: Yue Du
  7. Author-email: ifduyue@gmail.com
  8. License: BSD
  9. Classifier: Development Status :: 5 - Production/Stable
  10. Classifier: License :: OSI Approved :: BSD License
  11. Classifier: Intended Audience :: Developers
  12. Classifier: Programming Language :: Python
  13. Classifier: Programming Language :: Python :: 3
  14. Classifier: Programming Language :: Python :: 3 :: Only
  15. Classifier: Programming Language :: Python :: 3.7
  16. Classifier: Programming Language :: Python :: 3.8
  17. Classifier: Programming Language :: Python :: 3.9
  18. Classifier: Programming Language :: Python :: 3.10
  19. Classifier: Programming Language :: Python :: 3.11
  20. Classifier: Programming Language :: Python :: 3.12
  21. Classifier: Programming Language :: Python :: 3.13
  22. Classifier: Programming Language :: Python :: 3.14
  23. Classifier: Programming Language :: Python :: Implementation :: CPython
  24. Classifier: Programming Language :: Python :: Free Threading :: 1 - Unstable
  25. Requires-Python: >=3.7
  26. Description-Content-Type: text/x-rst
  27. License-File: LICENSE
  28. Dynamic: author
  29. Dynamic: author-email
  30. Dynamic: classifier
  31. Dynamic: description
  32. Dynamic: description-content-type
  33. Dynamic: home-page
  34. Dynamic: license
  35. Dynamic: license-file
  36. Dynamic: requires-python
  37. Dynamic: summary
  38. python-xxhash
  39. =============
  40. .. image:: https://github.com/ifduyue/python-xxhash/actions/workflows/test.yml/badge.svg
  41. :target: https://github.com/ifduyue/python-xxhash/actions/workflows/test.yml
  42. :alt: Github Actions Status
  43. .. image:: https://img.shields.io/pypi/v/xxhash.svg
  44. :target: https://pypi.org/project/xxhash/
  45. :alt: Latest Version
  46. .. image:: https://img.shields.io/pypi/pyversions/xxhash.svg
  47. :target: https://pypi.org/project/xxhash/
  48. :alt: Supported Python versions
  49. .. image:: https://img.shields.io/pypi/l/xxhash.svg
  50. :target: https://pypi.org/project/xxhash/
  51. :alt: License
  52. .. _HMAC: http://en.wikipedia.org/wiki/Hash-based_message_authentication_code
  53. .. _xxHash: https://github.com/Cyan4973/xxHash
  54. .. _Cyan4973: https://github.com/Cyan4973
  55. xxhash is a Python binding for the xxHash_ library by `Yann Collet`__.
  56. __ Cyan4973_
  57. Installation
  58. ------------
  59. .. code-block:: bash
  60. $ pip install xxhash
  61. You can also install using conda:
  62. .. code-block:: bash
  63. $ conda install -c conda-forge python-xxhash
  64. Installing From Source
  65. ~~~~~~~~~~~~~~~~~~~~~~~
  66. .. code-block:: bash
  67. $ pip install --no-binary xxhash xxhash
  68. Prerequisites
  69. ++++++++++++++
  70. On Debian/Ubuntu:
  71. .. code-block:: bash
  72. $ apt-get install python-dev gcc
  73. On CentOS/Fedora:
  74. .. code-block:: bash
  75. $ yum install python-devel gcc redhat-rpm-config
  76. Linking to libxxhash.so
  77. ~~~~~~~~~~~~~~~~~~~~~~~~
  78. By default python-xxhash will use bundled xxHash,
  79. we can change this by specifying ENV var ``XXHASH_LINK_SO``:
  80. .. code-block:: bash
  81. $ XXHASH_LINK_SO=1 pip install --no-binary xxhash xxhash
  82. Usage
  83. --------
  84. Module version and its backend xxHash library version can be retrieved using
  85. the module properties ``VERSION`` AND ``XXHASH_VERSION`` respectively.
  86. .. code-block:: python
  87. >>> import xxhash
  88. >>> xxhash.VERSION
  89. '2.0.0'
  90. >>> xxhash.XXHASH_VERSION
  91. '0.8.0'
  92. This module is hashlib-compliant, which means you can use it in the same way as ``hashlib.md5``.
  93. | update() -- update the current digest with an additional string
  94. | digest() -- return the current digest value
  95. | hexdigest() -- return the current digest as a string of hexadecimal digits
  96. | intdigest() -- return the current digest as an integer
  97. | copy() -- return a copy of the current xxhash object
  98. | reset() -- reset state
  99. md5 digest returns bytes, but the original xxh32 and xxh64 C APIs return integers.
  100. While this module is made hashlib-compliant, ``intdigest()`` is also provided to
  101. get the integer digest.
  102. Constructors for hash algorithms provided by this module are ``xxh32()`` and ``xxh64()``.
  103. For example, to obtain the digest of the byte string ``b'Nobody inspects the spammish repetition'``:
  104. .. code-block:: python
  105. >>> import xxhash
  106. >>> x = xxhash.xxh32()
  107. >>> x.update(b'Nobody inspects')
  108. >>> x.update(b' the spammish repetition')
  109. >>> x.digest()
  110. b'\xe2);/'
  111. >>> x.digest_size
  112. 4
  113. >>> x.block_size
  114. 16
  115. More condensed:
  116. .. code-block:: python
  117. >>> xxhash.xxh32(b'Nobody inspects the spammish repetition').hexdigest()
  118. 'e2293b2f'
  119. >>> xxhash.xxh32(b'Nobody inspects the spammish repetition').digest() == x.digest()
  120. True
  121. An optional seed (default is 0) can be used to alter the result predictably:
  122. .. code-block:: python
  123. >>> import xxhash
  124. >>> xxhash.xxh64('xxhash').hexdigest()
  125. '32dd38952c4bc720'
  126. >>> xxhash.xxh64('xxhash', seed=20141025).hexdigest()
  127. 'b559b98d844e0635'
  128. >>> x = xxhash.xxh64(seed=20141025)
  129. >>> x.update('xxhash')
  130. >>> x.hexdigest()
  131. 'b559b98d844e0635'
  132. >>> x.intdigest()
  133. 13067679811253438005
  134. Be careful that xxh32 takes an unsigned 32-bit integer as seed, while xxh64
  135. takes an unsigned 64-bit integer. Although unsigned integer overflow is
  136. defined behavior, it's better not to make it happen:
  137. .. code-block:: python
  138. >>> xxhash.xxh32('I want an unsigned 32-bit seed!', seed=0).hexdigest()
  139. 'f7a35af8'
  140. >>> xxhash.xxh32('I want an unsigned 32-bit seed!', seed=2**32).hexdigest()
  141. 'f7a35af8'
  142. >>> xxhash.xxh32('I want an unsigned 32-bit seed!', seed=1).hexdigest()
  143. 'd8d4b4ba'
  144. >>> xxhash.xxh32('I want an unsigned 32-bit seed!', seed=2**32+1).hexdigest()
  145. 'd8d4b4ba'
  146. >>>
  147. >>> xxhash.xxh64('I want an unsigned 64-bit seed!', seed=0).hexdigest()
  148. 'd4cb0a70a2b8c7c1'
  149. >>> xxhash.xxh64('I want an unsigned 64-bit seed!', seed=2**64).hexdigest()
  150. 'd4cb0a70a2b8c7c1'
  151. >>> xxhash.xxh64('I want an unsigned 64-bit seed!', seed=1).hexdigest()
  152. 'ce5087f12470d961'
  153. >>> xxhash.xxh64('I want an unsigned 64-bit seed!', seed=2**64+1).hexdigest()
  154. 'ce5087f12470d961'
  155. ``digest()`` returns bytes of the **big-endian** representation of the integer
  156. digest:
  157. .. code-block:: python
  158. >>> import xxhash
  159. >>> h = xxhash.xxh64()
  160. >>> h.digest()
  161. b'\xefF\xdb7Q\xd8\xe9\x99'
  162. >>> h.intdigest().to_bytes(8, 'big')
  163. b'\xefF\xdb7Q\xd8\xe9\x99'
  164. >>> h.hexdigest()
  165. 'ef46db3751d8e999'
  166. >>> format(h.intdigest(), '016x')
  167. 'ef46db3751d8e999'
  168. >>> h.intdigest()
  169. 17241709254077376921
  170. >>> int(h.hexdigest(), 16)
  171. 17241709254077376921
  172. Besides xxh32/xxh64 mentioned above, oneshot functions are also provided,
  173. so we can avoid allocating XXH32/64 state on heap:
  174. | xxh32_digest(bytes, seed=0)
  175. | xxh32_intdigest(bytes, seed=0)
  176. | xxh32_hexdigest(bytes, seed=0)
  177. | xxh64_digest(bytes, seed=0)
  178. | xxh64_intdigest(bytes, seed=0)
  179. | xxh64_hexdigest(bytes, seed=0)
  180. .. code-block:: python
  181. >>> import xxhash
  182. >>> xxhash.xxh64('a').digest() == xxhash.xxh64_digest('a')
  183. True
  184. >>> xxhash.xxh64('a').intdigest() == xxhash.xxh64_intdigest('a')
  185. True
  186. >>> xxhash.xxh64('a').hexdigest() == xxhash.xxh64_hexdigest('a')
  187. True
  188. >>> xxhash.xxh64_hexdigest('xxhash', seed=20141025)
  189. 'b559b98d844e0635'
  190. >>> xxhash.xxh64_intdigest('xxhash', seed=20141025)
  191. 13067679811253438005L
  192. >>> xxhash.xxh64_digest('xxhash', seed=20141025)
  193. '\xb5Y\xb9\x8d\x84N\x065'
  194. .. code-block:: python
  195. In [1]: import xxhash
  196. In [2]: %timeit xxhash.xxh64_hexdigest('xxhash')
  197. 268 ns ± 24.1 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
  198. In [3]: %timeit xxhash.xxh64('xxhash').hexdigest()
  199. 416 ns ± 17.3 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
  200. XXH3 hashes are available since v2.0.0 (xxHash v0.8.0), they are:
  201. Streaming classes:
  202. | xxh3_64
  203. | xxh3_128
  204. Oneshot functions:
  205. | xxh3_64_digest(bytes, seed=0)
  206. | xxh3_64_intdigest(bytes, seed=0)
  207. | xxh3_64_hexdigest(bytes, seed=0)
  208. | xxh3_128_digest(bytes, seed=0)
  209. | xxh3_128_intdigest(bytes, seed=0)
  210. | xxh3_128_hexdigest(bytes, seed=0)
  211. And aliases:
  212. | xxh128 = xxh3_128
  213. | xxh128_digest = xxh3_128_digest
  214. | xxh128_intdigest = xxh3_128_intdigest
  215. | xxh128_hexdigest = xxh3_128_hexdigest
  216. Caveats
  217. -------
  218. SEED OVERFLOW
  219. ~~~~~~~~~~~~~~
  220. xxh32 takes an unsigned 32-bit integer as seed, and xxh64 takes
  221. an unsigned 64-bit integer as seed. Make sure that the seed is greater than
  222. or equal to ``0``.
  223. ENDIANNESS
  224. ~~~~~~~~~~~
  225. As of python-xxhash 0.3.0, ``digest()`` returns bytes of the
  226. **big-endian** representation of the integer digest. It used
  227. to be little-endian.
  228. DONT USE XXHASH IN HMAC
  229. ~~~~~~~~~~~~~~~~~~~~~~~
  230. Though you can use xxhash as an HMAC_ hash function, but it's
  231. highly recommended not to.
  232. xxhash is **NOT** a cryptographic hash function, it is a
  233. non-cryptographic hash algorithm aimed at speed and quality.
  234. Do not put xxhash in any position where cryptographic hash
  235. functions are required.
  236. Copyright and License
  237. ---------------------
  238. Copyright (c) 2014-2025 Yue Du - https://github.com/ifduyue
  239. Licensed under `BSD 2-Clause License <http://opensource.org/licenses/BSD-2-Clause>`_
  240. CHANGELOG
  241. -----------
  242. v3.6.0 2025-10-02
  243. ~~~~~~~~~~~~~~~~~
  244. - Build wheels for Python 3.14
  245. - Python free-threading support
  246. - Typing: Use Buffer type stubs
  247. - Deprecate xxhash.VERSION_TUPLE, it will be removed in the next major release
  248. v3.5.0 2024-08-17
  249. ~~~~~~~~~~~~~~~~~
  250. - Build wheels for Python 3.13
  251. v3.4.1 2023-10-05
  252. ~~~~~~~~~~~~~~~~~
  253. - Build wheels for Python 3.12
  254. - Remove setuptools_scm
  255. v3.4.0 2023-10-05
  256. ~~~~~~~~~~~~~~~~~
  257. *Yanked* due to wheels building problem.
  258. v3.3.0 2023-07-29
  259. ~~~~~~~~~~~~~~~~~
  260. - Upgrade xxHash to v0.8.2
  261. - Drop support for Python 3.6
  262. v3.2.0 2022-12-28
  263. ~~~~~~~~~~~~~~~~~
  264. This is the last version to support Python 3.6
  265. - Build Python 3.11 wheels.
  266. - Remove setup.py test_suites, call unittest directly
  267. v3.1.0 2022-10-19
  268. ~~~~~~~~~~~~~~~~~
  269. - Type annotations.
  270. - Enabled muslinux wheels building.
  271. v3.0.0 2022-02-25
  272. ~~~~~~~~~~~~~~~~~
  273. - New set `algorithms_available` lists all implemented algorithms in `xxhash`
  274. package.
  275. - Upgrade xxHash to v0.8.1.
  276. - Drop support for EOL Python versions, require python >= 3.6 from now on.
  277. - Migrate to github actions and build arm64 wheels for macOS.
  278. - Always release GIL.
  279. v2.0.2 2021-04-15
  280. ~~~~~~~~~~~~~~~~~
  281. - Fix Travis CI OSX dpl python2.7 get-pip.py error
  282. v2.0.1 2021-04-15
  283. ~~~~~~~~~~~~~~~~~
  284. - Only to trigger Python 3.9 wheels building.
  285. v2.0.0 2020-08-03
  286. ~~~~~~~~~~~~~~~~~
  287. - **Require xxHash version >= v0.8.0**
  288. - Upgrade xxHash to v0.8.0
  289. - XXH3 hashes: `xxh3_64`, `xxh3_128`, and their oneshot functions
  290. v1.4.4 2020-06-20
  291. ~~~~~~~~~~~~~~~~~
  292. - Upgrade xxHash to v0.7.3
  293. - Stop using PEP393 deprecated APIs
  294. - Use XXH(32|64)_canonicalFromHash to replace u2bytes and ull2bytes
  295. v1.4.3 2019-11-12
  296. ~~~~~~~~~~~~~~~~~
  297. - Upgrade xxHash to v0.7.2
  298. - Python 3.8 wheels
  299. v1.4.2 2019-10-13
  300. ~~~~~~~~~~~~~~~~~
  301. - Fixed: setup.py fails when reading README.rst and the default encoding is not UTF-8
  302. v1.4.1 2019-08-27
  303. ~~~~~~~~~~~~~~~~~
  304. - Fixed: xxh3.h in missing from source tarball
  305. v1.4.0 2019-08-25
  306. ~~~~~~~~~~~~~~~~~
  307. - Upgrade xxHash to v0.7.1
  308. v1.3.0 2018-10-21
  309. ~~~~~~~~~~~~~~~~~
  310. - Wheels are now built automatically
  311. - Split CFFI variant into a separate package `ifduyue/python-xxhash-cffi <https://github.com/ifduyue/python-xxhash-cffi>`_
  312. v1.2.0 2018-07-13
  313. ~~~~~~~~~~~~~~~~~
  314. - Add oneshot functions xxh{32,64}_{,int,hex}digest
  315. v1.1.0 2018-07-05
  316. ~~~~~~~~~~~~~~~~~
  317. - Allow input larger than 2GB
  318. - Release the GIL on sufficiently large input
  319. - Drop support for Python 3.2
  320. v1.0.1 2017-03-02
  321. ~~~~~~~~~~~~~~~~~~
  322. - Free state actively, instead of delegating it to ffi.gc
  323. v1.0.0 2017-02-10
  324. ~~~~~~~~~~~~~~~~~~
  325. - Fixed copy() segfault
  326. - Added CFFI variant
  327. v0.6.3 2017-02-10
  328. ~~~~~~~~~~~~~~~~~~
  329. - Fixed copy() segfault
  330. v0.6.2 2017-02-10
  331. ~~~~~~~~~~~~~~~~~~
  332. - Upgrade xxHash to v0.6.2
  333. v0.6.1 2016-06-26
  334. ~~~~~~~~~~~~~~~~~~
  335. - Upgrade xxHash to v0.6.1
  336. v0.5.0 2016-03-02
  337. ~~~~~~~~~~~~~~~~~~
  338. - Upgrade xxHash to v0.5.0
  339. v0.4.3 2015-08-21
  340. ~~~~~~~~~~~~~~~~~~
  341. - Upgrade xxHash to r42
  342. v0.4.1 2015-08-16
  343. ~~~~~~~~~~~~~~~~~~
  344. - Upgrade xxHash to r41
  345. v0.4.0 2015-08-05
  346. ~~~~~~~~~~~~~~~~~~
  347. - Added method reset
  348. - Upgrade xxHash to r40
  349. v0.3.2 2015-01-27
  350. ~~~~~~~~~~~~~~~~~~
  351. - Fixed some typos in docstrings
  352. v0.3.1 2015-01-24
  353. ~~~~~~~~~~~~~~~~~~
  354. - Upgrade xxHash to r39
  355. v0.3.0 2014-11-11
  356. ~~~~~~~~~~~~~~~~~~
  357. - Change digest() from little-endian representation to big-endian representation of the integer digest.
  358. This change breaks compatibility (digest() results are different).
  359. v0.2.0 2014-10-25
  360. ~~~~~~~~~~~~~~~~~~
  361. - Make this package hashlib-compliant
  362. v0.1.3 2014-10-23
  363. ~~~~~~~~~~~~~~~~~~
  364. - Update xxHash to r37
  365. v0.1.2 2014-10-19
  366. ~~~~~~~~~~~~~~~~~~
  367. - Improve: Check XXHnn_init() return value.
  368. - Update xxHash to r36
  369. v0.1.1 2014-08-07
  370. ~~~~~~~~~~~~~~~~~~
  371. - Improve: Can now be built with Visual C++ Compiler.
  372. v0.1.0 2014-08-05
  373. ~~~~~~~~~~~~~~~~~~
  374. - New: XXH32 and XXH64 type, which support partially update.
  375. - Fix: build under Python 3.4
  376. v0.0.2 2014-08-03
  377. ~~~~~~~~~~~~~~~~~~
  378. - NEW: Support Python 3
  379. v0.0.1 2014-07-30
  380. ~~~~~~~~~~~~~~~~~~
  381. - NEW: xxh32 and xxh64