GithubHelp home page GithubHelp logo

jayvdb / python-zstd Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sergey-dryabzhinsky/python-zstd

0.0 3.0 0.0 88 KB

Simple python bindings to Yann Collet ZSTD compression library

License: BSD 2-Clause "Simplified" License

Python 52.50% C 47.50%

python-zstd's Introduction

python-zstd

https://travis-ci.org/sergey-dryabzhinsky/python-zstd.svg?branch=master

Simple python bindings to Yann Collet ZSTD compression library

Zstd, short for Zstandard, is a new lossless compression algorithm,
which provides both good compression ratio _and_ speed for your standard compression needs. "Standard" translates into everyday situations which neither look for highest possible ratio (which LZMA and ZPAQ cover) nor extreme speeds (which LZ4 covers).

It is provided as a BSD-license package, hosted on GitHub.

WARNING!!!

If you setup 1.0.0.99.1 version - remove it manualy to able to update. PIP matching version strings not tuple of numbers.

Result generated by versions prior to 1.0.0.99.1 is not compatible with orignial Zstd by any means. It generates custom header and can be read only by zstd python module.

As of 1.0.0.99.1 version it uses standard Zstd output, not modified.

To prevent data loss there is two functions now: `compress_old` and `decompress_old`. They are works just like in old versions prior to 1.0.0.99.1.

As of 1.1.4 version module build without them by default.

As of 1.3.4 version these functions are deprecated and will be removed in future releases.

DISCLAIMER

These python bindings are kept simple and blunt.

Support of dictionaries is not planned.

LINKS

Build from source

>>> $ git clone https://github.com/sergey-dryabzhinsky/python-zstd
>>> $ git submodule update --init
>>> $ apt-get install python-dev python3-dev python-setuptools python3-setuptools
>>> $ python setup.py build_ext clean
>>> $ python3 setup.py build_ext clean

Note: legacy format support disabled by default. To build with legacy support - pass --legacy option to setup.py script:

>>> $ python setup.py build_ext --legacy clean

If you want to build with existing distribution of libzstd just add --external option. But beware! Legacy formats support is unknown in this case.

>>> $ python setup.py build_ext --external clean

If paths to header file zstd.h and libraries is uncommon - use common build params: --libraries --include-dirs --library-dirs.

>>> $ python setup.py build_ext --external --include-dirs /opt/zstd/usr/include --libraries zstd --library-dirs /opt/zstd/lib clean

Install from pypi

>>> # for Python 2.6+
>>> $ pip install zstd
>>> # or for Python 3.2+
>>> $ pip3 install zstd

Use

Module has simple API:

>>> import zstd
>>> dir(zstd)
['Error', 'ZSTD_compress', 'ZSTD_uncompress', 'ZSTD_version', 'ZSTD_version_number', '__doc__', '__file__', '__name__', '__package__', 'compress', 'decompress', 'dumps', 'loads', 'uncompress', 'version']
>>> zstd.version()
'1.3.8.0'
>>> zstd.ZSTD_version()
'1.3.8'
>>> zstd.ZSTD_version_number()
10308
>>> data = "123456qwert"
>>> cdata = zstd.compress(data, 1)
>>> data == zstd.decompress(cdata)
True

python-zstd's People

Contributors

sergey-dryabzhinsky avatar eli-b avatar

Watchers

John Vandenberg avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.