Разработана утилита для многопоточного сжатия файлов WebAssembly
This commit is contained in:
44
app/algorithms.py
Normal file
44
app/algorithms.py
Normal file
@ -0,0 +1,44 @@
|
||||
import gzip
|
||||
import zlib
|
||||
|
||||
import brotli
|
||||
import zstandard
|
||||
|
||||
|
||||
def compress_with_brotli(
|
||||
data: bytes,
|
||||
level: int,
|
||||
):
|
||||
return brotli.compress(
|
||||
data,
|
||||
quality=level,
|
||||
)
|
||||
|
||||
|
||||
def compress_with_zstandard(
|
||||
data: bytes,
|
||||
level: int,
|
||||
):
|
||||
return zstandard.ZstdCompressor(
|
||||
level=level,
|
||||
).compress(data)
|
||||
|
||||
|
||||
def compress_with_gzip(
|
||||
data: bytes,
|
||||
level: int,
|
||||
):
|
||||
return gzip.compress(
|
||||
data,
|
||||
compresslevel=level,
|
||||
)
|
||||
|
||||
|
||||
def compress_with_deflate(
|
||||
data: bytes,
|
||||
level: int,
|
||||
):
|
||||
return zlib.compress(
|
||||
data,
|
||||
level=level,
|
||||
)
|
Reference in New Issue
Block a user