Skip to content

Reference#

Rust crate documentation is at docs.rs. For development versions, the documentation is here.

LZOCompressor #

Object containing the compressor state.

Reusing a single instance of this class reuses compressor-memory, reducing allocations.

Thread safety

Instance and static methods are thread-safe.

Source code in python/lzallright/_lzallright.pyi
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
class LZOCompressor:
    """Object containing the compressor state.

    Reusing a single instance of this class reuses compressor-memory,
    reducing allocations.

    Thread safety:
        Instance and static methods are thread-safe.
    """

    def compress(self, data: Buffer) -> bytes:
        """Compresses data.

        Args:
            data (bytes): Any python object that implements the buffer protocol

        Note:
            The GIL (Global Interpreter Lock) is released for the duration of this
            function.
        """
    @staticmethod
    def decompress(data: Buffer, output_size_hint: int | None = None) -> bytes:
        """Decompresses data.

        Args:
            data (bytes): Any python object that implements the buffer protocol
            output_size_hint: Preallocate output buffer to this size.
                Helps reducing memory overhead if decompressed size is known in advance.

        Note:
            The GIL (Global Interpreter Lock) is released for the duration of this
            function.
        """

compress #

compress(data)

Compresses data.

Parameters:

Name Type Description Default
data bytes

Any python object that implements the buffer protocol

required
Note

The GIL (Global Interpreter Lock) is released for the duration of this function.

Source code in python/lzallright/_lzallright.pyi
17
18
19
20
21
22
23
24
25
26
def compress(self, data: Buffer) -> bytes:
    """Compresses data.

    Args:
        data (bytes): Any python object that implements the buffer protocol

    Note:
        The GIL (Global Interpreter Lock) is released for the duration of this
        function.
    """

decompress staticmethod #

decompress(data, output_size_hint=None)

Decompresses data.

Parameters:

Name Type Description Default
data bytes

Any python object that implements the buffer protocol

required
output_size_hint int | None

Preallocate output buffer to this size. Helps reducing memory overhead if decompressed size is known in advance.

None
Note

The GIL (Global Interpreter Lock) is released for the duration of this function.

Source code in python/lzallright/_lzallright.pyi
27
28
29
30
31
32
33
34
35
36
37
38
39
@staticmethod
def decompress(data: Buffer, output_size_hint: int | None = None) -> bytes:
    """Decompresses data.

    Args:
        data (bytes): Any python object that implements the buffer protocol
        output_size_hint: Preallocate output buffer to this size.
            Helps reducing memory overhead if decompressed size is known in advance.

    Note:
        The GIL (Global Interpreter Lock) is released for the duration of this
        function.
    """

EResult #

Error codes in LZOError.args[0].

Source code in python/lzallright/_lzallright.pyi
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
class EResult:
    """Error codes in [`LZOError.args[0]`][lzallright._lzallright.LZOError.args]."""

    LookbehindOverrun = ...
    "Invalid input"
    OutputOverrun = ...
    """Buffer is not long enough to hold output.

    Warning:
        lzallright always tries to find the appropriate buffer size.
        If you see this, it is an error.
    """
    InputOverrun = ...
    "Input to decompress is truncated"
    Error = ...
    "Other error occurred"
    InputNotConsumed = ...
    "See [`InputNotConsumed`][lzallright._lzallright.InputNotConsumed]"

LookbehindOverrun class-attribute instance-attribute #

LookbehindOverrun = ...

Invalid input

OutputOverrun class-attribute instance-attribute #

OutputOverrun = ...

Buffer is not long enough to hold output.

Warning

lzallright always tries to find the appropriate buffer size. If you see this, it is an error.

InputOverrun class-attribute instance-attribute #

InputOverrun = ...

Input to decompress is truncated

Error class-attribute instance-attribute #

Error = ...

Other error occurred

InputNotConsumed class-attribute instance-attribute #

InputNotConsumed = ...

LZOError #

Bases: Exception

Fatal error during compression/decompression.

Source code in python/lzallright/_lzallright.pyi
60
61
62
63
64
65
66
class LZOError(Exception):
    """Fatal error during compression/decompression."""

    args: tuple[EResult]
    """Error reason.

    See [`EResult`][lzallright._lzallright.EResult]"""

args instance-attribute #

args

Error reason.

See EResult

InputNotConsumed #

Bases: LZOError

Decompression finished with leftover data.

Source code in python/lzallright/_lzallright.pyi
68
69
70
71
72
73
74
75
class InputNotConsumed(LZOError):  # noqa: N818
    """Decompression finished with leftover data."""

    args: tuple[EResult, bytes]  # type: ignore[assignment]
    """Error reason, with decompressed data

    ``(EResult.InputNotConsumed, decompressed: bytes)``
    """

args instance-attribute #

args

Error reason, with decompressed data

(EResult.InputNotConsumed, decompressed: bytes)