### Python Example Source: https://milesgranger.github.io/cramjam/cramjam/zlib.html Example of using the compress function. ```python >>> cramjam.zlib.compress(b'some bytes here', level=2, output_len=Optional[int]) # Level defaults to 6 ``` -------------------------------- ### Python Example Source: https://milesgranger.github.io/cramjam/cramjam/zlib.html Example of using the decompress function. ```python >>> cramjam.zlib.decompress(compressed_bytes, output_len=Optional[int]) ``` -------------------------------- ### Python Example Source: https://milesgranger.github.io/cramjam/cramjam/cramjam.html Example of how to use the File class to write bytes to a file. ```python from cramjam import File file = File("/tmp/file.txt") file.write(b"bytes") ``` -------------------------------- ### Python Example for compress Source: https://milesgranger.github.io/cramjam/cramjam/deflate.html Deflate compression function. ```python >>> cramjam.deflate.compress(b'some bytes here', level=5, output_len=Optional[int]) # level defaults to 6 ``` -------------------------------- ### Python Example Source: https://milesgranger.github.io/cramjam/cramjam/bzip2.html Decompression function signature. ```python >>> cramjam.bzip2.decompress(compressed_bytes, output_len=Optional[int]) ``` -------------------------------- ### Python Example Source: https://milesgranger.github.io/cramjam/cramjam/xz.html LZMA decompression. bytes or bytearray; bytearray is faster ```python >>> # bytes or bytearray; bytearray is faster >>> cramjam.xz.decompress(compressed_bytes, output_len=Optional[None]) ``` -------------------------------- ### Python Example Source: https://milesgranger.github.io/cramjam/cramjam/cramjam.html Example of how to use the Buffer class to create a buffer from bytes and read from it. ```python >>> from cramjam import Buffer >>> buf = Buffer(b"bytes") >>> buf.read() b'bytes' ``` -------------------------------- ### Python Example Source: https://milesgranger.github.io/cramjam/cramjam/bzip2.html Compression function signature with optional level and output length. ```python >>> cramjam.bzip2.compress(b'some bytes here', level=6, output_len=Option[int]) # level defaults to 6 ``` -------------------------------- ### Python Example for decompress Source: https://milesgranger.github.io/cramjam/cramjam/deflate.html Deflate decompression function. ```python >>> cramjam.deflate.decompress(compressed_bytes, output_len=Optional[int]) ``` -------------------------------- ### ZSTD compression Source: https://milesgranger.github.io/cramjam/cramjam/zstd.html Example of using the compress function. ```python >>> cramjam.zstd.compress(b'some bytes here', level=0, output_len=Optional[int]) # level defaults to 11 ``` -------------------------------- ### Python Example Source: https://milesgranger.github.io/cramjam/cramjam/xz.html LZMA compression. Defaults to XZ format, you can use the deprecated LZMA format like this: ```python >>> _ = cramjam.xz.compress(b'some bytes here') >>> # Defaults to XZ format, you can use the deprecated LZMA format like this: >>> _ = cramjam.xz.compress(b'some bytes here', format=cramjam.xz.Format.ALONE) ``` -------------------------------- ### ZSTD decompression Source: https://milesgranger.github.io/cramjam/cramjam/zstd.html Example of using the decompress function. ```python >>> cramjam.zstd.decompress(compressed_bytes, output_len=Optional[int]) ``` -------------------------------- ### Get max compressed length for raw compression Source: https://milesgranger.github.io/cramjam/cramjam/snappy.html Calculates the expected maximum compressed length for Snappy raw compression. This is the size of the buffer needed for `compress_raw_into`. ```python def compress_raw_max_len(data): ``` -------------------------------- ### Get decompressed length for raw data Source: https://milesgranger.github.io/cramjam/cramjam/snappy.html Determines the decompressed length of the given raw Snappy data. This is the size of the buffer needed for `decompress_raw_into`. ```python def decompress_raw_len(data): ``` -------------------------------- ### Decompressor class - len method Source: https://milesgranger.github.io/cramjam/cramjam/gzip.html Method to get the length of the internal buffer containing decompressed data. ```python def len(self, /): ``` -------------------------------- ### Gzip compression Source: https://milesgranger.github.io/cramjam/cramjam/gzip.html Demonstrates the usage of the `compress` function for Gzip compression, including the `level` parameter. ```python >>> cramjam.gzip.compress(b'some bytes here', level=2, output_len=Optional[int]) # Level defaults to 6 ``` -------------------------------- ### Import cramjam Source: https://milesgranger.github.io/cramjam Import all functions from the cramjam library. ```python 1from .cramjam import * ``` -------------------------------- ### Compressor stream finish Source: https://milesgranger.github.io/cramjam/cramjam/snappy.html Consumes the current compressor state and returns the final compressed stream. The compressor is unusable after this. ```python def finish(self, /): ``` -------------------------------- ### Compress raw format into output buffer Source: https://milesgranger.github.io/cramjam/cramjam/snappy.html Compresses data in raw Snappy format directly into a specified output buffer. ```python def compress_raw_into(input, output): ``` -------------------------------- ### Consume the current compressor state and return the compressed stream **NB** The compressor will not be usable after this method is called. Source: https://milesgranger.github.io/cramjam/cramjam/lz4.html Consume the current compressor state and return the compressed stream **NB** The compressor will not be usable after this method is called. ```python def finish(self, /): Consume the current compressor state and return the compressed stream **NB** The compressor will not be usable after this method is called. ``` -------------------------------- ### Compressor stream compression Source: https://milesgranger.github.io/cramjam/cramjam/snappy.html Compresses input data into the current compressor's stream. ```python def compress(self, /, input): ``` -------------------------------- ### Compress into output buffer Source: https://milesgranger.github.io/cramjam/cramjam/snappy.html Compresses data directly into a specified output buffer. ```python def compress_into(input, output): ``` -------------------------------- ### Gzip decompression Source: https://milesgranger.github.io/cramjam/cramjam/gzip.html Demonstrates the usage of the `decompress` function for Gzip decompression. ```python >>> cramjam.gzip.decompress(compressed_bytes, output_len=Optional[int]) ``` -------------------------------- ### Compressor stream flush Source: https://milesgranger.github.io/cramjam/cramjam/snappy.html Flushes the current compressed stream and returns the compressed data. ```python def flush(self, /): ``` -------------------------------- ### Snappy compression Source: https://milesgranger.github.io/cramjam/cramjam/snappy.html Compresses data using Snappy. Can optionally specify the output length. Using bytearray is recommended for performance. ```python >>> _ = cramjam.snappy.compress(b'some bytes here') >>> _ = cramjam.snappy.compress(bytearray(b'this avoids double allocation in rust side, and thus faster!')) # <- use bytearray where possible ``` -------------------------------- ### Snappy raw compression Source: https://milesgranger.github.io/cramjam/cramjam/snappy.html Compresses data using Snappy in raw format, without the 'framed' encoding. Can optionally specify the output length. ```python >>> cramjam.snappy.compress_raw(b'some bytes here') ``` -------------------------------- ### Finish compression stream Source: https://milesgranger.github.io/cramjam/cramjam/brotli.html Consume the current compressor state and return the compressed stream **NB** The compressor will not be usable after this method is called. ```python def finish(self, /): ``` -------------------------------- ### Decompress raw format into output buffer Source: https://milesgranger.github.io/cramjam/cramjam/snappy.html Decompresses data in raw Snappy format directly into a specified output buffer. ```python def decompress_raw_into(input, output): ``` -------------------------------- ### Compressor.finish Source: https://milesgranger.github.io/cramjam/cramjam/deflate.html Consume the current compressor state and return the compressed stream **NB** The compressor will not be usable after this method is called. ```python def finish(self, /): Consume the current compressor state and return the compressed stream **NB** The compressor will not be usable after this method is called. ``` -------------------------------- ### Flush and return current compressed stream Source: https://milesgranger.github.io/cramjam/cramjam/lz4.html Flush and return current compressed stream ```python def flush(self, /): Flush and return current compressed stream ``` -------------------------------- ### Compressor.flush Source: https://milesgranger.github.io/cramjam/cramjam/deflate.html Flush and return current compressed stream ```python def flush(self, /): Flush and return current compressed stream ``` -------------------------------- ### Decompress into output buffer Source: https://milesgranger.github.io/cramjam/cramjam/snappy.html Decompresses data directly into a specified output buffer. ```python def decompress_into(input, output): ``` -------------------------------- ### Consume the current Decompressor state and return the decompressed stream **NB** The Decompressor will not be usable after this method is called. Source: https://milesgranger.github.io/cramjam/cramjam/lz4.html Consume the current Decompressor state and return the decompressed stream **NB** The Decompressor will not be usable after this method is called. ```python def finish(self, /): Consume the current Decompressor state and return the decompressed stream **NB** The Decompressor will not be usable after this method is called. ``` -------------------------------- ### Compress directly into an output buffer Source: https://milesgranger.github.io/cramjam/cramjam/brotli.html Compress directly into an output buffer. -------------------------------- ### Compressor.compress Source: https://milesgranger.github.io/cramjam/cramjam/deflate.html Compress input into the current compressor's stream. ```python def compress(self, /, input): Compress input into the current compressor's stream. ``` -------------------------------- ### Compress directly into an output buffer Source: https://milesgranger.github.io/cramjam/cramjam/gzip.html Function signature for compressing data directly into an output buffer. ```python def compress_into(input, output, level=None): ``` -------------------------------- ### Flush and return current compressed stream Source: https://milesgranger.github.io/cramjam/cramjam/brotli.html Flush and return current compressed stream. ```python def flush(self, /): ``` -------------------------------- ### Compress input into the current compressor's stream. Source: https://milesgranger.github.io/cramjam/cramjam/lz4.html Compress input into the current compressor's stream. ```python def compress(self, /, input): Compress input into the current compressor's stream. ``` -------------------------------- ### LZ4 compression Source: https://milesgranger.github.io/cramjam/cramjam/lz4.html LZ4 compression. Note, output_len is currently ignored; underlying algorithm does not support reading to slice at this time ```python >>> # Note, output_len is currently ignored; underlying algorithm does not support reading to slice at this time >>> cramjam.lz4.compress(b'some bytes here', output_len=Optional[int]) ``` -------------------------------- ### Brotli compression Source: https://milesgranger.github.io/cramjam/cramjam/brotli.html Brotli compression function signature. ```python >>> cramjam.brotli.compress(b'some bytes here', level=9, output_len=Option[int]) # level defaults to 11 ``` -------------------------------- ### Brotli Compressor object for streaming compression Source: https://milesgranger.github.io/cramjam/cramjam/brotli.html Compress input into the current compressor's stream. ```python def compress(self, /, input): ``` -------------------------------- ### Flush and return current decompressed stream. Source: https://milesgranger.github.io/cramjam/cramjam/lz4.html Flush and return current decompressed stream. ```python def flush(self, /): Flush and return current decompressed stream. ``` -------------------------------- ### Decompressor.finish Source: https://milesgranger.github.io/cramjam/cramjam/deflate.html Consume the current Decompressor state and return the decompressed stream **NB** The Decompressor will not be usable after this method is called. ```python def finish(self, /): Consume the current Decompressor state and return the decompressed stream **NB** The Decompressor will not be usable after this method is called. ``` -------------------------------- ### Decompress directly into an output buffer Source: https://milesgranger.github.io/cramjam/cramjam/gzip.html Function signature for decompressing data directly into an output buffer. ```python def decompress_into(input, output): ``` -------------------------------- ### Snappy raw decompression Source: https://milesgranger.github.io/cramjam/cramjam/snappy.html Decompresses Snappy compressed data without using the 'framed' encoding. Can optionally specify the output length. ```python >>> cramjam.snappy.decompress_raw(compressed_raw_bytes) ``` -------------------------------- ### Decompressor stream decompression Source: https://milesgranger.github.io/cramjam/cramjam/snappy.html Decompresses input data into the internal buffer of the decompressor. ```python def decompress(self, /, input): ``` -------------------------------- ### LZ4 _block_ decompression Source: https://milesgranger.github.io/cramjam/cramjam/lz4.html LZ4 _block_ decompression. `output_len` is optional, it's the upper bound length of decompressed data; if it's not provided, then it's assumed `store_size=True` was used during compression and length will then be taken from the header, otherwise it's assumed `store_size=False` was used and no prepended size exists in input ```python >>> cramjam.lz4.decompress_block(compressed_bytes, output_len=Optional[int]) ``` -------------------------------- ### Decompressor.flush Source: https://milesgranger.github.io/cramjam/cramjam/deflate.html Flush and return current decompressed stream. ```python def flush(self, /): Flush and return current decompressed stream. ``` -------------------------------- ### Decompressor.decompress Source: https://milesgranger.github.io/cramjam/cramjam/deflate.html Decompress this input into the inner buffer. ```python def decompress(self, /, input): Decompress this input into the inner buffer. ``` -------------------------------- ### Decompressor object for streaming decompression Source: https://milesgranger.github.io/cramjam/cramjam/brotli.html Decompress this input into the inner buffer. ```python def decompress(self, /, input): ``` -------------------------------- ### Snappy decompression Source: https://milesgranger.github.io/cramjam/cramjam/snappy.html Decompresses Snappy compressed data. Can optionally specify the output length. ```python >>> # bytes or bytearray; bytearray is faster >>> cramjam.snappy.decompress(compressed_bytes, output_len=Optional[None]) ``` -------------------------------- ### Decompress this input into the inner buffer. Source: https://milesgranger.github.io/cramjam/cramjam/lz4.html Decompress this input into the inner buffer. ```python def decompress(self, /, input): Decompress this input into the inner buffer. ``` -------------------------------- ### LZ4 decompression Source: https://milesgranger.github.io/cramjam/cramjam/lz4.html LZ4 decompression. Note, output_len is currently ignored; underlying algorithm does not support reading to slice at this time ```python >>> # Note, output_len is currently ignored; underlying algorithm does not support reading to slice at this time >>> cramjam.lz4.decompress(compressed_bytes, output_len=Optional[int]) ``` -------------------------------- ### Determine the size of a buffer which is guaranteed to hold the result of block compression, will error if data is too long to be compressed by LZ4. Source: https://milesgranger.github.io/cramjam/cramjam/lz4.html Determine the size of a buffer which is guaranteed to hold the result of block compression, will error if data is too long to be compressed by LZ4. ```python >>> cramjam.lz4.compress_block_bound(b'some bytes here') ``` -------------------------------- ### LZ4 _block_ compression into pre-allocated buffer Source: https://milesgranger.github.io/cramjam/cramjam/lz4.html LZ4 _block_ compression into pre-allocated buffer. The kwargs mostly follow the same definition found in python-lz4 block.compress ```python >>> cramjam.lz4.compress_block_into( ... b'some bytes here', ... output=output_buffer, ... mode=Option[str], ... acceleration=Option[int], ... compression=Option[int], ... store_size=Option[bool] ... ) ``` -------------------------------- ### LZ4 _block_ compression Source: https://milesgranger.github.io/cramjam/cramjam/lz4.html LZ4 _block_ compression. The kwargs mostly follow the same definition found in python-lz4 block.compress ```python >>> cramjam.lz4.compress_block( ... b'some bytes here', ... output_len=Optional[int], ... mode=Option[str], ... acceleration=Option[int], ... compression=Option[int], ... store_size=Option[bool] ... ) ``` -------------------------------- ### Brotli decompression Source: https://milesgranger.github.io/cramjam/cramjam/brotli.html Brotli decompression function signature. ```python >>> cramjam.brotli.decompress(compressed_bytes, output_len=Optional[int]) ``` -------------------------------- ### Decompressor.len Source: https://milesgranger.github.io/cramjam/cramjam/deflate.html Length of internal buffer containing decompressed data. ```python def len(self, /): Length of internal buffer containing decompressed data. ``` -------------------------------- ### LZ4 _block_ decompression into a pre-allocated buffer Source: https://milesgranger.github.io/cramjam/cramjam/lz4.html LZ4 _block_ decompression into a pre-allocated buffer. ```python >>> cramjam.lz4.decompress_block_into(compressed_bytes, output_buffer) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.