Registry / serialization / crc32c

crc32c

JSON →
library2.9pypypi✓ verified 26d ago

The `crc32c` Python package provides an implementation of the CRC32C checksum algorithm, intelligently leveraging hardware acceleration (Intel SSE 4.2, ARMv8 crc32 instructions) when available, and falling back to an optimized software implementation otherwise. As of version 2.8, it offers robust data integrity verification across various platforms. The library aims for regular updates.

pip install crc32c
INSTALL
IMPORT
SIG · CRC32C
C
crc32c
serializationpythonv2.9
Install
1.7s avg
Import
113ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.9 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.118s · 18MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.7s · import 0.108s · 19MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

crc32c
import crc32c
Main module import
crc32c
crc32c.crc32c(data)
crc32c.crc32(data)
The 'crc32c.crc32' function is deprecated; use 'crc32c.crc32c' instead for the core checksum calculation.
CRC32CHash
from crc32c import CRC32CHash
For streaming checksum calculations with a hash-like object.

Demonstrates basic CRC32C calculation, incremental updates, usage of the `CRC32CHash` object, and how to check for hardware acceleration.

import crc32c # Calculate CRC32C for a byte string data = b"hello world" checksum = crc32c.crc32c(data) print(f"CRC32C checksum of '{data.decode()}': {checksum}") # Incremental calculation (similar to binascii.crc32 with 'value' parameter) crc_part1 = crc32c.crc32c(b"hello") crc_total = crc32c.crc32c(b" world", value=crc_part1) print(f"Incremental CRC32C: {crc_total}") # Using the hash-like object hash_obj = crc32c.CRC32CHash() hash_obj.update(b"hello") hash_obj.update(b" world") print(f"CRC32CHash object checksum: {hash_obj.checksum}") # Check if hardware acceleration is in use print(f"Hardware acceleration in use: {crc32c.hardware_based}")
Debug
Known issues
deprecatedThe `crc32c.crc32` function is deprecated and will be removed in future versions. Users should switch to `crc32c.crc32c` for all checksum calculations.
fix
Replace `crc32c.crc32(...)` with `crc32c.crc32c(...)`.
affects: <=2.8
gotchaThe `auto` value for the `CRC32C_SW_MODE` environment variable, which controls software fallback behavior, is planned for discontinuation. It's recommended to explicitly use `force` or `none` if specific fallback control is needed.
fix
If setting `CRC32C_SW_MODE`, use `force` to always use software implementation or `none` to raise an error if hardware is unavailable, instead of `auto`.
affects: All versions
breakingIn versions up to 2.6, an `ImportError` was raised if no hardware support was found and software fallback was not enabled. As of version 2.7, this behavior has changed: `CRC32C_SW_MODE='none'` will now issue a `RuntimeWarning` on import and a `RuntimeError` on execution if hardware support is missing.
fix
Update exception handling for `crc32c` import/execution to catch `RuntimeWarning` or `RuntimeError` when `CRC32C_SW_MODE='none'` is set, instead of `ImportError`.
affects: >=2.7 (breaking change from <=2.6)
gotchaThe project uses specific `gcc`/`clang` compiler extensions. If installing from source (e.g., when no pre-built wheel is available for your platform/Python version), older compiler versions might fail to build the package.
fix
Ensure your C/C++ compiler (gcc/clang/Visual Studio) is up-to-date and supports modern extensions. Using a platform with pre-built binary wheels from PyPI is the easiest way to avoid this.
affects: All versions (when building from source)
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'crc32c'
The `crc32c` package is either not installed in the current Python environment, or there's a conflict with other similarly named libraries, or the `brew install crc32c` command installed a C library, not the Python package.
fix
Ensure the Python package is installed using pip: `pip install crc32c`. Verify you are in the correct Python environment. If `google-crc32c` is also installed and causing conflicts, try managing dependencies carefully or isolating environments.
AttributeError: module 'crc32c' has no attribute 'crc32'
The `crc32` function name is deprecated in `crc32c` versions 2.x and later, in favor of `crc32c` (lowercase).
fix
Update your code to use the `crc32c()` function instead of the deprecated `crc32()` function: `import crc32c; checksum = crc32c.crc32c(data)`.
RuntimeError: No hardware crc32c support found and CRC32C_SW_MODE is 'none'
This error occurs when the `CRC32C_SW_MODE` environment variable is explicitly set to 'none', preventing the library from falling back to a software implementation if hardware CRC32C support is not detected on the CPU.
fix
Either ensure your CPU has hardware CRC32C support (Intel SSE 4.2 or ARMv8 crc32 instructions), or allow the software fallback by unsetting `CRC32C_SW_MODE` or setting it to 'auto' or 'force'. Example: `export CRC32C_SW_MODE=force` (before running your Python script).
ERROR: Could not build wheels for crc32c which use PEP 517 and cannot be installed directly
This issue typically arises during installation when pre-built binary wheels are not available for your specific Python version and operating system, and the system lacks the necessary C compiler and development headers to compile the `crc32c` C extension from source.
fix
Install the required build tools for your operating system (e.g., `build-essential` on Debian/Ubuntu, Xcode Command Line Tools on macOS, or Visual Studio Build Tools on Windows). Alternatively, try installing a specific version for which a wheel might exist, or ensure you are on a widely supported platform/Python version.
Upgrade
Version history
2.9latest on PyPI · released Aug 21, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
30 hits · last 30 days
node
28
Resources
crc32c — pip install crc32c · libregistry