pyppmd provides classes and functions for compressing and decompressing text data, using PPM (Prediction by partial matching) compression algorithm variation H and I.2. It provide an API similar to Python's zlib/bz2/lzma modules.
Find a file
Hiroshi Miura 44879781f5
All checks were successful
ci/woodpecker/push/check/3 Pipeline was successful
ci/woodpecker/push/check/5 Pipeline was successful
ci/woodpecker/push/check/2 Pipeline was successful
ci/woodpecker/push/check/4 Pipeline was successful
ci/woodpecker/push/check/1 Pipeline was successful
chore: fix woodpeker-ci to drop 3.8
Signed-off-by: Hiroshi Miura <miurahr@linux.com>
2024-12-23 12:39:42 +09:00
.woodpecker chore: fix woodpeker-ci to drop 3.8 2024-12-23 12:39:42 +09:00
ci/azure-pipelines chore: azure pipelines scripts 2023-11-04 21:26:17 +09:00
docs Docs: update file structures 2022-05-18 14:40:03 +09:00
issue_template Configure for codeberg CI 2022-07-27 08:56:06 +09:00
src Initialize values 2024-05-06 08:54:52 +09:00
tests Skip benchmark tests if cpuinfo module is not supported 2024-05-06 09:28:33 +09:00
utils Benchmark: drop ratex print 2021-04-22 08:14:27 +09:00
.flake8 Drop setup.cfg 2022-11-15 12:44:55 +09:00
.git_archival.txt chore: allow build on git export source tree 2023-11-07 15:45:10 +09:00
.gitattributes chore: allow build on git export source tree 2023-11-07 15:45:10 +09:00
.gitignore chore: update tox configuration 2023-11-04 18:40:25 +09:00
Changelog.rst Release v1.1.1 2024-12-23 10:53:26 +09:00
CMakeLists.txt chore: allow build on git export source tree 2023-11-07 15:45:10 +09:00
LICENSE Update License notifications 2022-05-18 12:11:31 +09:00
MANIFEST.in chore: fix sdist config 2023-11-04 10:56:56 +09:00
pyproject.toml chore: min python version 3.9 2024-12-23 08:39:43 +09:00
README.rst chore: minimum version of python 3.8 2023-11-03 15:45:58 +09:00
SECURITY.rst Update Security policy 2022-11-15 14:56:17 +09:00
setup.py chore: fix ffi_build (#122) 2023-11-04 09:12:36 +00:00

PyPPMd

image

image

image

image

Introduction

pyppmd module provides classes and functions for compressing and decompressing text data, using PPM(Prediction by partial matching) compression algorithm which has several variations of implementations. PPMd is the implementation by Dmitry Shkarin. PyPPMD use Igor Pavlov's range coder introduced in 7-zip.

The API is similar to Python's bz2/lzma/zlib module.

Some parts of th codes are derived from 7-zip, pyzstd and ppmd-cffi.

Development status

A project status is considered as Stable.

Extra input byte

PPMd algorithm and implementation is designed to use Extra input byte. The encoder will omit a last null (b"0") byte when last byte is b"0". You may need to provide an extra null byte when you don't get expected size of extracted data.

You can do like as:

dec = pyppmd.Ppmd7Decoder(max_order=6, mem_size=16 << 10)
result = dec.decode(compressed, length)
if len(result) < length:
    if dec.needs_input:
        # ppmd need an extra null byte
        result += dec.decode(b"\0", length - len(result))
    else:
        result += dec.decode(b"", length - len(result))

Warning

When use it on MSYS2/MINGW64 environment, you should set environment variable SETUPTOOLS_USE_DISTUTILS=stdlib

Some codes are derived from p7zip/7zip and pyzstd project. Details are shown in LicenseNotices.rst

PyPPMd is licensed under GNU Lesser General Public License v2.1 or later.

  • Copyright (C) 2020-2023 Hiroshi Miura
  • Copyright (C) 2020-2021 Ma Lin
  • Copyright (C) 2010-2012 Lockless Inc.
  • Copyright (C) 1999-2017 Igor Pavlov

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA