Package: crc32c
This package implements the crc32c checksum algorithm.
It automatically chooses between a hardware-based implementation
(using the CRC32C SSE 4.2 instruction of Intel CPUs,
and the crc32* instructions on ARMv8 CPUs),
or a software-based one when no hardware support can be found.Becausecrc32cis in PyPI, you can install it with:pip install crc32cSupported platforms are Linux and OSX using the gcc and clang compilers,
and Windows using the Visual Studio compiler. Other compilers in
Windows (MinGW for instance) might work.
Binary wheels are also provided in PyPI for major platforms/architectures.The project is using certain gcc/clang compiler extensions to support
building hardware-specific functions that might not be supported
by older compiler versions.UsageThe only method exposed by this module iscrc32c(data, [crc]).
It computes the CRC32C checksum ofdatastarting with an initialcrcchecksum,
similarly to how the built-inbinascii.crc32works.
It can thus be used like this:print(crc32c.crc32c(b'hello world'))# 3381945770crc=crc32c.crc32c(b'hello')print(crc32c.crc32c(b' world',crc))# 3381945770In older versions,
the function exposed by this module was calledcrc32.
That name is still present but deprecated,
and will be removed in new versions of the library.Additionally one can consult
the following module-level values:hardware_basedindicates if the algorithm in use
is software- or hardware-based.big_endianindicates whether the platform is big endian or not.Implementation detailsBy default,
if your CPU doesn’t have CRC32C hardware support,
the package will fallback to use a software implementation
of the crc32c checksum algorithm.
This behavior can be changed by setting
theCRC32C_SW_MODEenvironment variable
to one of the following values:auto: same as if unset, will eventually be discontinued.force: use software implementation regardless of hardware support.none: fail to import the module with anImportErrorif no hardware support is found (old 1.x default behavior).The software algorithm is based
on Intel’sslice-by-8 package,
with some adaptations done
byEvan Jonesand packaging provided byFerry Toth.
Further adaptations were required
to make the code more portable
and fit for inclusion within this python package.The Intel SSE 4.2 algorithm
is based onMark Adler’s code,
with some modifications required
to make the code more portable
and fit for inclusion within this python package.The ARMv8 hardware implementation
is based on Google’scrc32cC++ library.CopyrightThis package is copyrighted:ICRAR - International Centre for Radio Astronomy Research
(c) UWA - The University of Western Australia, 2017
Copyright by UWA (in the framework of the ICRAR)The original slice-by-8 software algorithm
is copyrighted by:Copyright (c) 2004-2006 Intel Corporation - All Rights ReservedFurther adaptations to the slice-by-8 algorithm
previous to the inclusion in this package
are copyrighted by:Copyright 2008,2009,2010 Massachusetts Institute of Technology.The original Intel SSE 4.2 crc32c algorithm
is copyrighted by:Copyright (C) 2013 Mark AdlerThe crc32c ARMv8 hardware code
is copyrighted by:Copyright 2017 The CRC32C AuthorsA copy of theAUTHORSfile
from Google’s crc32c project
as it was at the time of copying the code
is included in this repository.LicenseThis package is licensed underthe LGPL-2.1 license.The original slice-by-8 software algorithm
is licensed underthe 2-clause BSD licence.Further modifications to the slice-by-8 software algorithm
are licensed undera 3-clause BSD licenceThe original Intel SSE 4.2 crc32c algorithm’s code
is licensed under a custom license
embedded in thecrc32c_adler.cfile.The original crc32c ARMv8 hardware code
is licensed undera 3-clause BSD license.