Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Faster zlib and gzip compatible compression and decompression by providing python bindings for the isa-l library.

License

NotificationsYou must be signed in to change notification settings

pycompression/python-isal

Repository files navigation

python-isal

Faster zlib and gzip compatible compression and decompressionby providing Python bindings for the ISA-L library.

This package provides Python bindings for theISA-L library. The Intel(R) Intelligent StorageAcceleration Library (ISA-L) implements several key algorithms inassemblylanguage. This includesa variety of functions to provide zlib/gzip-compatible compression.

python-isal provides the bindings by offering four modules:

  • isal_zlib: A drop-in replacement for the zlib module that uses ISA-L toaccelerate its performance.
  • igzip: A drop-in replacement for the gzip module that usesisal_zlibinstead ofzlib to perform its compression and checksum tasks, whichimproves performance.
  • igzip_threaded offers anopen function which returns buffered reador write streams that can be used to read and write large files whileescaping the GIL using one or multiple threads. This functionality onlyworks for streaming, seeking is not supported.
  • igzip_lib: Provides compression functions which have full access to theAPI of ISA-L's compression functions.

isal_zlib andigzip are almost fully compatible withzlib andgzip from the Python standard library. There are some minor differencessee:differences-with-zlib-and-gzip-modules.

Quickstart

The python-isal modules can be imported as follows

fromisalimportisal_zlibfromisalimportigzipfromisalimportigzip_lib

isal_zlib andigzip are meant to be used as drop in replacements sotheir api and functions are the same as the stdlib's modules. Except whereISA-L does not support the same calls as zlib (See differences below).

A full API documentation can be found onour readthedocs page.

python -m isal.igzip implements a simple gzip-like command lineapplication (just likepython -m gzip). Full usage documentation can befound onour readthedocs page.

Installation

  • with pip:pip install isal
  • with conda:conda install python-isal

Installation is supported on Linux, Windows and MacOS. For more advancedinstallation options check thedocumentation.

python-isal as a dependency in your project

Python-isal supports a limited amount of platforms for which wheels have beenmade available. To prevent your users from running into issues when installingyour project please list a python-isal dependency as follows.

setup.cfg:

install_requires =    isal; platform.machine == "x86_64" or platform.machine == "AMD64" or platform.machine == "aarch64"

setup.py:

extras_require={    ":platform.machine == 'x86_64' or platform.machine == 'AMD64' or platform.machine == 'aarch64'": ['isal']},

Differences with zlib and gzip modules

  • Compression level 0 inzlib andgzip meansno compression, whileinisal_zlib andigzip this is thelowest compression level.This is a design choice that was inherited from the ISA-L library.
  • Compression levels range from 0 to 3, not 1 to 9.isal_zlib.Z_DEFAULT_COMPRESSIONhas been aliased toisal_zlib.ISAL_DEFAULT_COMPRESSION (2).
  • isal_zlib only supportsNO_FLUSH,SYNC_FLUSH,FULL_FLUSH andFINISH_FLUSH. Other flush modes are not supported and will raise errors.
  • zlib.Z_DEFAULT_STRATEGY,zlib.Z_RLE etc. are exposed asisal_zlib.Z_DEFAULT_STRATEGY,isal_zlib.Z_RLE etc. for compatibilityreasons. However,isal_zlib only supports a default strategy and willgive warnings when other strategies are used.
  • zlib supports different memory levels from 1 to 9 (with 8 default).isal_zlib supports memory levels smallest, small, medium, large andlargest. These have been mapped to levels 1, 2-3, 4-6, 7-8 and 9. Soisal_zlib can be used with zlib compatible memory levels.
  • igzip.open returns a classIGzipFile instead ofGzipFile. Sincethe compression levels are not compatible, a difference in naming was chosento reflect this.igzip.GzipFile does exist as an alias ofigzip.IGzipFile for compatibility reasons.
  • igzip._GzipReader has been rewritten in C. Since this is a private memberit should not affect compatibility, but it may cause some issues forinstances where this code is used directly. If such issues should occur,please report them so the compatibility issues can be fixed.

Contributing

Please make a PR or issue if you feel anything can be improved. Bug reportsare also very welcome. Please report them on thegithub issue tracker.

Development

The repository needs to be cloned recursively to make sure theISA-L repository is checked out:git clone --recursive https://github.com/pycompression/python-isal.git. Ifthe repository is already checked out you can usegit submodule update --init.

Patches should be made on a feature branch. To run the testing installtoxwithpip install tox and run the commandstox -e lint andtox. That will run most of the testing that is also performed by the CI.For changes to the documentation runtox -e docs. For changes to the Ccode please also runtox -e asan to check for memory leaks. This requireslibasan to be installed.

Building requires theISA-L build requirementsas well.

Acknowledgements

This project builds upon the software and experience of many. Many thanks to:

  • TheISA-L contributors for making ISA-L.Special thanks to @gbtucker for always being especially helpful andresponsive.
  • TheCython contributors for making it easyto create an extension and helping a novice get start with pointer addresses.
  • TheCPython contributors.Python-isal mimickszlibmodule.c andgzip.py from the standardlibrary to make it easier for python users to adopt it.
  • @marcelm for taking a chance on this projectand make it a dependency for hisxopen and by extensioncutadapt projects. This gave python-isal itsfirst users who used python-isal in production.
  • Mark Adler (@madler) for the excellent comments in his pigz code which madeit very easy to replicate the behaviour for writing gzip with multiplethreads using thethreading andisal_zlib modules. Another thanksfor his permissive license, which allowed the crc32_combine code to beincluded in the project. (ISA-L does not provide a crc32_combine function,unlike zlib.) And yet another thanks to Mark Adler and also forJean-loup Gailly for creating the gzip format which is very heavily usedin bioinformatics. Without that, I would have never written this libraryfrom which I have learned so much.
  • Thegithub actions team forcreating the actions CI service that enables building and testing on allthree major operating systems.
  • @animalize for explaining how to test andbuild python-isal for ARM 64-bit platforms.
  • And last but not least: everyone who submitted a bug report or a featurerequest. These make the project better!

Python-isal would not have been possible without you!

About

Faster zlib and gzip compatible compression and decompression by providing python bindings for the isa-l library.

Topics

Resources

License

Stars

Watchers

Forks


[8]ページ先頭

©2009-2025 Movatter.jp