Skip to main content

aplib

A pure Python module for decompressing aPLib compressed data

Adapted from the original C source code from http://ibsensoftware.com/files/aPLib-1.1.1.zip
Approximately 20 times faster than other Python implementations.
Compatible with both Python 2 and 3.

Usage

import aplib

data = aplib.decompress(packed)                    # raw aPLib stream or AP32 headered data
data = aplib.decompress(packed, max_size=1 << 20)  # lower the limit for the unpacked size
data = aplib.decompress(packed, headered=False)    # never parse an AP32 header
data = aplib.decompress(packed, strict=False)      # keep the data decoded before the first stream error

Decompression errors raise aplib.APLibError, a subclass of RuntimeError.

Untrusted input

The defaults are meant to be safe for untrusted input, such as data extracted from malware:

  • max_size limits the unpacked data to aplib.DEFAULT_MAX_SIZE (64 MiB) by default. Exceeding it raises APLibError, even with strict=False. Unpacking up to 64 MiB in pure Python can still take several seconds of CPU time, so pass a smaller max_size when processing many untrusted inputs. max_size=None disables the limit; only use it for trusted input.
  • If an AP32 header is parsed, the original size in the header limits the unpacked data too, even with strict=False (exceeding it raises APLibError). To salvage a stream whose header has a wrong original size, slice past the header and pass headered=False, strict=False.
  • strict=True (the default) rejects malformed data, and checks the sizes and CRC32 checksums in the AP32 header. CRC32 detects accidental corruption, not deliberate tampering.
  • headered=None (the default) treats input of at least 24 bytes starting with AP32 as having an AP32 header; an invalid header size raises APLibError, even with strict=False. Pass headered=True to require a complete AP32 header (raising APLibError if it is missing or truncated), or headered=False to ignore any header.

Changes in 0.8

  • decompress() is strict by default (strict=True).
  • decompress() and APLib limit the unpacked data to DEFAULT_MAX_SIZE by default, and exceeding max_size raises APLibError in non-strict mode too, instead of truncating the output.
  • An AP32 header with an invalid header size (or a missing or truncated header when headered=True) raises APLibError in non-strict mode too, instead of being decompressed as data, and the original size in the header limits the unpacked data in both modes.
  • New headered argument for decompress().
  • Input that isn't a bytes-like object, such as an integer, raises TypeError.
  • MemoryError and OverflowError in the decompression loop raise APLibError, even in non-strict mode (converting the final output buffer to bytes can still raise MemoryError).

Metadata

Release files for aplib 0.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aplib 0.8
File Size Uploaded Provenance Actions
aplib-0.8.tar.gz 46.7 kB With provenance Details for aplib-0.8.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for aplib 0.8
File Interpreter ABI Platform Actions
aplib-0.8-py2.py3-none-any.whl Python 2, Python 3 none any Details for aplib-0.8-py2.py3-none-any.whl

Total release size: 76.5 kB

Release files / aplib-0.8.tar.gz

Download URL aplib-0.8.tar.gz
Size 46.7 kB
Tags Source
SHA-256 checksum
How to use checksums
f01c4297152849d18d985a0b85da8a5e36e882e22e7fa86a26a7b95f61f5b8ce
BLAKE2b-256 checksum
How to use checksums
658248764f34b0641c4d8ce03b71d8403a4c5b94a5925fe4204e7ae0d7133de6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

Release files / aplib-0.8-py2.py3-none-any.whl

Download URL aplib-0.8-py2.py3-none-any.whl
Size 29.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
a015bb3ed6bf95d9d20a7b93f4f55bbdfdeb8cf8ab5fdee05152f114aa49dfd4
BLAKE2b-256 checksum
How to use checksums
74dc0e2a69ab1a5d955d989665e439c7bce1cb9821567a400fbfc16a9d73f080
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

Security for aplib 0.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for aplib-0.8.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page