Introduction

pyhash is a python non-cryptographic hash library.
It provides several common hash algorithms with C/C++ implementation for performance and compatibility.
>>> import pyhash
>>> hasher = pyhash.fnv1_32()
>>> hasher('hello world')
2805756500L
>>> hasher('hello', ' ', 'world')
2805756500L
>>> hasher('world', seed=hasher('hello '))
2805756500L
It also can be used to generate fingerprints without seed.
>>> import pyhash
>>> fp = pyhash.farm_fingerprint_64()
>>> fp('hello')
>>> 13009744463427800296L
>>> fp('hello', 'world')
>>> [13009744463427800296L, 16436542438370751598L]
Notes
hasher('hello', ' ', 'world') is a syntax sugar for hasher('world', seed=hasher(' ', seed=hasher('hello'))), and may not equals to hasher('hello world'), because some hash algorithms use different hash and seed size.
For example, metro hash always use 32bit seed for 64/128 bit hash value.
>>> import pyhash
>>> hasher = pyhash.metro_64()
>>> hasher('hello world')
>>> 5622782129197849471L
>>> hasher('hello', ' ', 'world')
>>> 16402988188088019159L
>>> hasher('world', seed=hasher(' ', seed=hasher('hello')))
>>> 16402988188088019159L
Installation
$ pip install pyhash
Notes
If pip install failed with similar errors, #27
/usr/lib/gcc/x86_64-linux-gnu/6/include/smmintrin.h:846:1: error: inlining failed in call to always_inline 'long long unsigned int _mm_crc32_u64(long long unsigned int, long long unsigned int)': target specific option mismatch
_mm_crc32_u64 (unsigned long long __C, unsigned long long __V)
^~~~~~~~~~~~~
src/smhasher/metrohash64crc.cpp:52:34: note: called from here
v[0] ^= _mm_crc32_u64(v[0], read_u64(ptr)); ptr += 8;
~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
Please upgrade pip and setuptools to latest version and try again
$ pip install --upgrade pip setuptools
Notes
If pip install failed on MacOS with similar errors #28
creating build/temp.macosx-10.6-intel-3.6
...
/usr/bin/clang -fno-strict-aliasing -Wsign-compare -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch i386 -arch x86_64 -g -c src/smhasher/metrohash64crc.cpp -o build/temp.macosx-10.6-intel-3.6/src/smhasher/metrohash64crc.o -msse4.2 -maes -mavx -mavx2
src/smhasher/metrohash64crc.cpp:52:21: error: use of undeclared identifier '_mm_crc32_u64'
v[0] ^= _mm_crc32_u64(v[0], read_u64(ptr)); ptr += 8;
^
You may try to
$ CFLAGS="-mmacosx-version-min=10.13" pip install pyhash
Notes
pyhash only support pypy v6.0 or newer, please download and install the latest pypy.
Algorithms
pyhash supports the following hash algorithms
- FNV (Fowler-Noll-Vo) hash
- fnv1_32
- fnv1a_32
- fnv1_64
- fnv1a_64
- MurmurHash
- murmur1_32
- murmur1_aligned_32
- murmur2_32
- murmur2a_32
- murmur2_aligned_32
- murmur2_neutral_32
- murmur2_x64_64a
- murmur2_x86_64b
- murmur3_32
- murmur3_x86_128
- murmur3_x64_128
- lookup3
- lookup3
- lookup3_little
- lookup3_big
- SuperFastHash
- super_fast_hash
- City Hash
_ city_32
- city_64
- city_128
- city_crc_128
- city_fingerprint_256
- Spooky Hash
- spooky_32
- spooky_64
- spooky_128
- FarmHash
- farm_32
- farm_64
- farm_128
- farm_fingerprint_32
- farm_fingerprint_64
- farm_fingerprint_128
- MetroHash
- metro_64
- metro_128
- metro_crc_64
- metro_crc_128
- MumHash
- mum_64
- T1Ha
- t1ha2 (64-bit little-endian)
- t1ha2_128 (128-bit little-endian)
- t1ha1 (64-bit native-endian)
- t1ha1_le (64-bit little-endian)
- t1ha1_be (64-bit big-endian)
- t1ha0 (64-bit, choice fastest function in runtime.)
t1_32t1_32_bet1_64t1_64_be
- XXHash
- xx_32
- xx_64
- xxh3_64 NEW
- xxh3_128 NEW
- Highway Hash
- highway_64 NEW
- highway_128 NEW
- highway_256 NEW
String and Bytes literals
Python has two types can be used to present string literals, the hash values of the two types are definitely different.
- For Python 2.x String literals,
strwill be used by default,unicodecan be used with theuprefix. - For Python 3.x String and Bytes literals,
unicodewill be used by default,bytescan be used with thebprefix.
For example,
$ python2
Python 2.7.15 (default, Jun 17 2018, 12:46:58)
[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyhash
>>> hasher = pyhash.murmur3_32()
>>> hasher('foo')
4138058784L
>>> hasher(u'foo')
2085578581L
>>> hasher(b'foo')
4138058784L
$ python3
Python 3.7.0 (default, Jun 29 2018, 20:13:13)
[Clang 9.1.0 (clang-902.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyhash
>>> hasher = pyhash.murmur3_32()
>>> hasher('foo')
2085578581
>>> hasher(u'foo')
2085578581
>>> hasher(b'foo')
4138058784
You can also import unicode_literals to use unicode literals in Python 2.x
from __future__ import unicode_literals
In general, it is more compelling to use unicode_literals when back-porting new or existing Python 3 code to Python 2/3 than when porting existing Python 2 code to 2/3. In the latter case, explicitly marking up all unicode string literals with u'' prefixes would help to avoid unintentionally changing the existing Python 2 API. However, if changing the existing Python 2 API is not a concern, using unicode_literals may speed up the porting process.
Metadata
Release files for pyhash2 0.9.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pyhash2-0.9.4.tar.gz | 1.4 MB | Without provenance | Details |
Built distributions (wheels)
Total release size: 4.6 MB
Release files / pyhash2-0.9.4.tar.gz
| Download URL | pyhash2-0.9.4.tar.gz |
|---|---|
| Size | 1.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
39d037c4fdf94ed737736ab2e77b4f28afe47345016cf9a128f9cdefdee42296
|
|
BLAKE2b-256 checksum How to use checksums |
434f9af03248cfe0a979fdd8282678968636a133cd06f5916a2073c2b7b027dc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.20
|
Release files / pyhash2-0.9.4-cp313-cp313-win_amd64.whl
| Download URL | pyhash2-0.9.4-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 235.8 kB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
ad5286d4d53158c786cf6eb469ef7161a8d69523007b391f918573e0841f3471
|
|
BLAKE2b-256 checksum How to use checksums |
88f294f40a6aaa8c210a0909ac1479df40b4e516056358e196ab4e65c319b25b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.13.0
|
Release files / pyhash2-0.9.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | pyhash2-0.9.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 262.2 kB |
| Tags | CPython 3.13 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
a8db1f3b3e03bd2a5b8872aab42c0af0272f7c5f5e898dbc0f9fed3b563debbd
|
|
BLAKE2b-256 checksum How to use checksums |
cbfcbacdf75c627fcdf20cad4f3e0e66c9f8707b9c4b906938117ba6b63f7381
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.20
|
Release files / pyhash2-0.9.4-cp312-cp312-win_amd64.whl
| Download URL | pyhash2-0.9.4-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 235.8 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
ee8d1805a85517dea017924a3c1639b160d2d4ee257c4297570aeaa5bd0a08ec
|
|
BLAKE2b-256 checksum How to use checksums |
30b9b0461d80ee789c54b772a3ac207f3a5a4bc5267952893789f18b90f98562
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Release files / pyhash2-0.9.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | pyhash2-0.9.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 261.1 kB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
5ef58766ff4a542f9ede627aa62f42e16f5c7be9b7ded857898925c121f03c0e
|
|
BLAKE2b-256 checksum How to use checksums |
6350ec3bdd6fb35edef301bc30e23b5bdaab46b05e1f2e84d7d6304fd7373e10
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.20
|
Release files / pyhash2-0.9.4-cp311-cp311-win_amd64.whl
| Download URL | pyhash2-0.9.4-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 236.1 kB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
ae89b5bfeddd1fd6c6d21b32f7a1e346829c179163c5c111f4fa610e85319877
|
|
BLAKE2b-256 checksum How to use checksums |
24907bf5f7dcec97253bce0a881115a9a0524d38701412ec7764a1ea30a0f601
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.9
|
Release files / pyhash2-0.9.4-cp311-cp311-manylinux_2_34_aarch64.manylinux_2_38_aarch64.whl
| Download URL | pyhash2-0.9.4-cp311-cp311-manylinux_2_34_aarch64.manylinux_2_38_aarch64.whl |
|---|---|
| Size | 221.6 kB |
| Tags | CPython 3.11 Linux glibc 2.34+ ARM64 Linux glibc 2.38+ ARM64 |
|
SHA-256 checksum How to use checksums |
6ede768bf65fd57ce84582e08c09d3bcaa4d297c1e0db958c1a5fd1b09a26d96
|
|
BLAKE2b-256 checksum How to use checksums |
b6ec13dd035ef4544e90d519116fb426dca025559fe29f5eb42239a89fb39c9e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.6
|
Release files / pyhash2-0.9.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | pyhash2-0.9.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 262.7 kB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
33ef84cefdaf2f0591bf2c82154d7b1c30300a4d432a247247cf71768f582c5a
|
|
BLAKE2b-256 checksum How to use checksums |
74c9fa6fa87ab34abcf43c4bbf69298a5c3961d27aac36cd6cc30b4d6f3fa191
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.20
|
Release files / pyhash2-0.9.4-cp310-cp310-win_amd64.whl
| Download URL | pyhash2-0.9.4-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 234.8 kB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
9baed6c86723b1b94b8689d8f0b071a5ff3d2b80987095b993e4c046166c7d00
|
|
BLAKE2b-256 checksum How to use checksums |
6108633b528cfd1b7764844998915e8cf408854b46096b1c97535e0415f36324
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.11
|
Release files / pyhash2-0.9.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | pyhash2-0.9.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 260.8 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
b24d90d2e2114a7349a5aa2b8ac0ffeee73617ea18a976c049aea6c9970ecef9
|
|
BLAKE2b-256 checksum How to use checksums |
a0bbb357e987eb8686912f048e3d9f51aad1c354ec6d9c0852ad11b0c25ed805
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.20
|
Release files / pyhash2-0.9.4-cp39-cp39-win_amd64.whl
| Download URL | pyhash2-0.9.4-cp39-cp39-win_amd64.whl |
|---|---|
| Size | 235.0 kB |
| Tags | CPython 3.9 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
1357dfd023f69fb29acdb2f42b9dacbe7d13632046b34b45200d66e3695894fd
|
|
BLAKE2b-256 checksum How to use checksums |
f75c63baea827a9eacd1c45bf4a29b16ddd2c9dc7e58126c6ace2340e792e2a1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.13
|
Release files / pyhash2-0.9.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | pyhash2-0.9.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 261.2 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
37db697cdb21d187441b633195bf5338b32bda6068e17aa08301ad956ee8c0ee
|
|
BLAKE2b-256 checksum How to use checksums |
523370f0e20a77f234c71989ece2e5d856fa068cf8ea4bbd8a5d5e1a13a08462
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.20
|
Release files / pyhash2-0.9.4-cp38-cp38-win_amd64.whl
| Download URL | pyhash2-0.9.4-cp38-cp38-win_amd64.whl |
|---|---|
| Size | 234.9 kB |
| Tags | CPython 3.8 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
b2de5fb2c153e90201ea09d3a38ab3ca881c98e8c2ee0cdfbd46c0940813ab81
|
|
BLAKE2b-256 checksum How to use checksums |
6521c254704aa3b29e6deea75b622c7095ffb001d6075f5ee7396df02aa381de
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.8.10
|
Release files / pyhash2-0.9.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | pyhash2-0.9.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 260.5 kB |
| Tags | CPython 3.8 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
9f2ea26106ee5a58e066977b0aa5bbe6f2be3f1d1c5cb997984418e25dff132b
|
|
BLAKE2b-256 checksum How to use checksums |
df322a49dbbafa7476adfeec2082535376095bc40b7ae3aa2a4078a37808621b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.20
|
Security for pyhash2 0.9.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.