Extensión de hashing SHA-256 acelerado con Rust y PyO3
Project description
devlacruz_hashlib
devlacruz_hashlib is a high-performance SHA-256 hashing library implemented in Rust with PyO3 bindings, offering ultra-fast hashing and GIL-free execution for Python applications.
Table of Contents
Features
- Ultra-fast SHA-256 hashing using optimized Rust code
- GIL-free execution for true parallelism in multi-threaded Python apps
- Cross-platform support: Linux, Windows, and macOS
- Pure-Python API: easy-to-use functions for integers, strings, and bytes
- Python 3.8+ compatibility
Installation
Install via pip:
pip install devlacruz_hashlib
Quick Start
import devlacruz_hashlib as dh
# Integer hash (simple)
hash_simple = dh.hash_id_simple(12345)
print(f"Simple integer hash: {hash_simple}")
# Integer hash (GIL-releasing)
hash_gil = dh.hash_id(12345)
print(f"GIL-free integer hash: {hash_gil}")
# String hash
hash_str = dh.hash_string("Hello, world!")
print(f"String hash: {hash_str}")
# Bytes hash
hash_bytes = dh.hash_bytes(b"binary data")
print(f"Bytes hash: {hash_bytes}")
API Reference
| Function | Signature | Description |
|---|---|---|
hash_id_simple |
hash_id_simple(x: int) -> str |
SHA-256 of integer (no GIL release) |
hash_id |
hash_id(x: int) -> str |
SHA-256 of integer (GIL released) |
hash_string |
hash_string(s: str) -> str |
SHA-256 of UTF-8 string (GIL released) |
hash_bytes |
hash_bytes(data: bytes) -> str |
SHA-256 of byte sequence (GIL released) |
Performance
Benchmark comparing Python’s hashlib vs. devlacruz_hashlib on 1 MB data (%):
import time, hashlib
import devlacruz_hashlib as dh
data = b"x" * 1_000_000 # 1 MB
# Python hashlib
t0 = time.perf_counter()
for _ in range(100):
hashlib.sha256(data).hexdigest()
py = time.perf_counter() - t0
# devlacruz_hashlib
t0 = time.perf_counter()
for _ in range(100):
dh.hash_bytes(data)
rust = time.perf_counter() - t0
print(f"hashlib: {py:.3f}s — devlacruz_hashlib: {rust:.3f}s")
print(f"Speedup: {py / rust:.1f}× faster")
Typical results:
**Python **``: 0.85 s devlacruz_hashlib: 0.15 s Speedup: ~5.7×
Use Cases
- Bulk data processing pipelines
- Cryptographic integrity checks
- High-throughput logging and analytics
- Multi-threaded Python applications requiring parallel hashing
Contributing
Contributions are welcome! To get started:
-
Fork this repository
-
Create a feature branch:
git checkout -b feature/your-feature-name
-
Commit your changes:
git commit -m "Add awesome feature"
-
Push to your branch:
git push origin feature/your-feature-name
-
Open a Pull Request detailing your changes.
Please ensure code follows project style and includes tests.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Author
Alejandro De La Cruz ✉️ devlacruz@axtosys.com
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file devlacruz_hashlib-0.1.6-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: devlacruz_hashlib-0.1.6-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 112.9 kB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b000094e7506dd107a152f78308a37e5a17219b574b26c466c45242f7dd5d114
|
|
| MD5 |
a646aa9cf74b068723a67722c9117e1f
|
|
| BLAKE2b-256 |
4275ed7d4701723641a0e295c6e602b841adc219c7e0e3d22fd48c96820692f1
|
File details
Details for the file devlacruz_hashlib-0.1.6-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: devlacruz_hashlib-0.1.6-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 185.6 kB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20741e5cd2bbe69672b4a395d4134776d8fe1b4a1dfc3f6b6ff15a2957fe1e32
|
|
| MD5 |
8a1e1a2d07f98a83491cd585c915afee
|
|
| BLAKE2b-256 |
fd7b310d9365098632e244df5a72f40f73089c12e51980165fb4b61fa9be4226
|
File details
Details for the file devlacruz_hashlib-0.1.6-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: devlacruz_hashlib-0.1.6-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 113.0 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ddf6eb3a0021949ec0b2708e146e265f5bdc95a7f452dc4a739826f68e7c6a9
|
|
| MD5 |
f25e4d347e10664ea4b804561c9bd86c
|
|
| BLAKE2b-256 |
cc14174dccdfce47860edf67ac2900b4637bdf8f02fb8fcd16fe8c1118a06a69
|
File details
Details for the file devlacruz_hashlib-0.1.6-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: devlacruz_hashlib-0.1.6-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 185.8 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
116fe72328990b169cdb7f7c4fc5c65606738cb43a8ffc44d3ff5d13b080ac6f
|
|
| MD5 |
a45a43c0f59ce0ef046514f70069caea
|
|
| BLAKE2b-256 |
63c4f8a4c85aea3a5c801990aa2fc44b4e40ffae71fc56e17a9a3d3f0abf9fb5
|
File details
Details for the file devlacruz_hashlib-0.1.6-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: devlacruz_hashlib-0.1.6-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 113.0 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
378acff102882a0a3e5134b387032428d10a356063d3d2475d0c536af939a70c
|
|
| MD5 |
1737f03ef34383856c01aac778bbd886
|
|
| BLAKE2b-256 |
251ac853cd83194c82be3865d93af5d59bb4bc7568b0fafc55daf9845cca0961
|
File details
Details for the file devlacruz_hashlib-0.1.6-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: devlacruz_hashlib-0.1.6-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 187.8 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ea148a60dfab3c0bec847c99a35709c31f32db24d99da44bc291944586cbeb7
|
|
| MD5 |
a896a441151de4f62b587dc794e4d3cc
|
|
| BLAKE2b-256 |
810c91f0eb1289eaa0097bbfb2cd1a24972b84da656a46b69999d719043abcad
|
File details
Details for the file devlacruz_hashlib-0.1.6-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: devlacruz_hashlib-0.1.6-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 113.1 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
16ad6d2c2f6ee0660ca70b0fb93221d39299a0c4aaca98d25187756089706f36
|
|
| MD5 |
130100c5c21e2731bf4f88e30ef9d594
|
|
| BLAKE2b-256 |
a2286311a084ca7611fef02bcb22e884f9560c0b5937b84645828d431c109869
|
File details
Details for the file devlacruz_hashlib-0.1.6-cp310-cp310-macosx_11_0_arm64.whl.
File metadata
- Download URL: devlacruz_hashlib-0.1.6-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 187.9 kB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
53ebc84cd48a5b4333fdaeab1dce9da1c222c9606f1080687a0bc0d46857f2cb
|
|
| MD5 |
ae6e39f35fc59d00dc6dedc2a9cf8ad8
|
|
| BLAKE2b-256 |
c09eeafb79b3a4648297dfa4e6b3d3e6caa0be494ff0e6b400164cabca62f1f4
|
File details
Details for the file devlacruz_hashlib-0.1.6-cp39-cp39-win_amd64.whl.
File metadata
- Download URL: devlacruz_hashlib-0.1.6-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 113.5 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03f57048319f4222eb13a119515135d4a5a8774e323cea82ca08998655c3d7b5
|
|
| MD5 |
92c1b2b77bd8143e05d4b21029bdbecd
|
|
| BLAKE2b-256 |
535ddac1dad20016428ffdf60846090f82a399af614f157fed4aae1e5e4ea230
|
File details
Details for the file devlacruz_hashlib-0.1.6-cp39-cp39-macosx_11_0_arm64.whl.
File metadata
- Download URL: devlacruz_hashlib-0.1.6-cp39-cp39-macosx_11_0_arm64.whl
- Upload date:
- Size: 188.4 kB
- Tags: CPython 3.9, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f28f7712d578e5d6e32689c9f897ccdb653f34198c82715861feca894da837e
|
|
| MD5 |
885c2ed9ee12331c2ab341ca4a4fe65b
|
|
| BLAKE2b-256 |
b2f9927a78be9aa70fb6c3fddb072c04ca24635c42ae3bd898166171c49a6d6c
|
File details
Details for the file devlacruz_hashlib-0.1.6-cp38-cp38-win_amd64.whl.
File metadata
- Download URL: devlacruz_hashlib-0.1.6-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 113.4 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35664314bc25255a6cf6189445d72c75f99a48d9542d7e08092ea020737b1d23
|
|
| MD5 |
25f53b9911c6590b8d4947f5d819384e
|
|
| BLAKE2b-256 |
26fb7371f46bd3d092a4894849fca8f5ec8cee2887ab63a0148bc9013ed1dcd2
|
File details
Details for the file devlacruz_hashlib-0.1.6-cp38-cp38-macosx_11_0_arm64.whl.
File metadata
- Download URL: devlacruz_hashlib-0.1.6-cp38-cp38-macosx_11_0_arm64.whl
- Upload date:
- Size: 188.1 kB
- Tags: CPython 3.8, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ebb807bdb466f22218d6168dc05f6b3f2d8d9e6075ce8e04ab94c07a29c39c9c
|
|
| MD5 |
824e1c9bc72c9d6e0238a82ac3ca2068
|
|
| BLAKE2b-256 |
97e8643a2756a42566a0e51f2a65fd4d23e5e33942f514023421f2ec6a8865e9
|
File details
Details for the file devlacruz_hashlib-0.1.6-cp38-abi3-win_amd64.whl.
File metadata
- Download URL: devlacruz_hashlib-0.1.6-cp38-abi3-win_amd64.whl
- Upload date:
- Size: 179.1 kB
- Tags: CPython 3.8+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46446f0a447a62c543e7a2e6e0984067d3c764d724276cbfe6e527b3a32ba4a9
|
|
| MD5 |
51ba9240fa83e0f95a40d8d7df58930e
|
|
| BLAKE2b-256 |
d65b509de2e7d96f2e38e6472d0d55769f54a30217bfd324ba670f8704fef323
|
File details
Details for the file devlacruz_hashlib-0.1.6-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: devlacruz_hashlib-0.1.6-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 278.4 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb28398996f7abbdf2d1121e6b6f2f576aea6432329f921ef8d459e8c9bde3bb
|
|
| MD5 |
a746c56b1df7b1f9b293addf9dfa8d03
|
|
| BLAKE2b-256 |
2adf1d9961e7b0524d1bcbe5a2c6fd26bc619a3c680482b9f87707d87d083d1f
|
File details
Details for the file devlacruz_hashlib-0.1.6-cp38-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: devlacruz_hashlib-0.1.6-cp38-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 241.8 kB
- Tags: CPython 3.8+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3688892da74571760f10772bc22c37d723c67a8ab4d3699a9d85515846dec4b2
|
|
| MD5 |
7139415474ae85efe37b494313c30bd2
|
|
| BLAKE2b-256 |
8abf7250de0196ea29230f208f3cf26e90e22ab661c2c4f0113d5d565ce5d43f
|
File details
Details for the file devlacruz_hashlib-0.1.6-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: devlacruz_hashlib-0.1.6-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 212.4 kB
- Tags: CPython 3.7m, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f95a78bcb6d258a7081e4afa2c4b5ca25f58a906120f7dfb1a5db2e435eb869
|
|
| MD5 |
e677c32a94b5dcf712d17546c42307a1
|
|
| BLAKE2b-256 |
2587ff2d408b55c49ad96430ec07ec844e9641d3782ec9f4710911b5f32fcce3
|