-
-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathcompress_decompress.py
More file actions
22 lines (18 loc) · 753 Bytes
/
compress_decompress.py
File metadata and controls
22 lines (18 loc) · 753 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#######################################################################
# Copyright (c) 2019-present, Blosc Development Team <blosc@blosc.org>
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#######################################################################
import array
# Compress and decompress different arrays
import blosc2
a = array.array("i", range(1000 * 1000))
a_bytesobj = a.tobytes()
c_bytesobj = blosc2.compress(a_bytesobj, typesize=4)
assert len(c_bytesobj) < len(a_bytesobj)
a_bytesobj2 = blosc2.decompress(c_bytesobj)
assert a_bytesobj == a_bytesobj2
dest = blosc2.compress(b"", 1)
assert blosc2.decompress(dest) == b""
assert type(blosc2.decompress(blosc2.compress(b"1" * 7, 1), as_bytearray=True)) is bytearray