Provide an efficient way to decompress a sequence of chunks compressed with ZstdCompressionChunker
Maintainer thường phản hồi trong vòng 4 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Lĩnh vực
- api, performance
Hướng nghiên cứu
Bắt đầu bằng cách xem xét ZstdCompressionChunker, ZstdDecompressor.read_to_iter và reproducer memoryview rút gọn trong issue. Xác định xem một API được hỗ trợ hiện có có thể xử lý các chunk đã nén theo từng phần hay không; nếu không, hãy xác định một cách tiếp cận chunk-to-chunk hiệu quả, tránh nối đầu vào hoặc đầu ra và không gây ra segfault, sau đó bổ sung coverage cho hành vi được báo cáo.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
My program wants to compress some large cached strings and decompress them later. I have no particular requirements on the form of the compressed data, so I used ZstdCompressionChunker to do the compression to avoid repeated reallocation of the output buffer. I would like to process the decompressed data in chunks to reduce peak memory usage. However there is no obvious efficient way to decompress chunks to chunks:
-
The ZstdCompressionChunker round-trip tests all concatenate the chunks with
bytes.joinfor one-shot decompression. (Fine, they're tests.) -
I tried
chain.from_iterable(dctx.read_to_iter(c) for c in chunks). This doesn't work because eachread_to_iteriterator expects to process a full stream. (I expected it to hold state in the ZstdDecompressor it was obtained from.) -
ZstdCompressionObj's documentation says it isn't efficient:
Because calls to decompress() may need to perform multiple memory (re)allocations, this streaming decompression API isn’t as efficient as other APIs.
-
read_to_iter's documentation saysread_to_iter() accepts an object with a read(size) method that will return compressed bytes or an object conforming to the buffer protocol.
so I wrote a class with a read method that returns memoryviews over the chunks (to avoid copying slices). The documentation is grammatically ambiguous; it turns out that
read_to_itersegfaults (!) when given an object with a read method that returns an object conforming to the buffer protocol that is not exactlybytes(reduced test case below).
My feature request is to provide an efficient way to decompress a sequence of chunks compressed with ZstdCompressionChunker (or to document an existing method as the efficient way, if there is one).
import zstandard as zstd
b = b'AB' * 1000
d = zstd.compress(b)
assert zstd.decompress(memoryview(d)) == b # passes
class Whatever:
def __init__(self, data):
self.data = data
def read(self, size):
assert len(data) <= size
return memoryview(self.data)
dctx = zstd.ZstdDecompressor()
assert b''.join(dctx.read_to_iter(Whatever(d))) == b # segfault
Segfaults using Arch Linux's python 3.13.2-1 and python-zstandard 0.23.0-2.
- Ngôn ngữ chính
- C
- Star
- 641
- Fork
- 117
- Merge trung bình
- 8 ngày 2 giờ
- Pull request đã merge (30 ngày)
- 7
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của indygreg/python-zstandard
-
`multi_decompress_to_buffer([])` terminates the process with SIGFPECó thể đã có người làm @mikamikasuki đã nhận 11 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
indygreg/python-zstandard#335 ·
Maintainer thường phản hồi trong vòng 4 ngày
-
Silent data-correctness bug: `readinto()` / `readinto1()` on `stream_reader` return `tell() == 0` after successful readsCó thể đã có người làm @CAOShurong đã nhận 4 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
indygreg/python-zstandard#295 ·
Maintainer thường phản hồi trong vòng 4 ngày
-
Python 3.15 wheelsCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 55/100
indygreg/python-zstandard#354 · 1 reaction ·
Maintainer thường phản hồi trong vòng 4 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 64/100
indygreg/python-zstandard#345 ·
Maintainer thường phản hồi trong vòng 4 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 55/100
indygreg/python-zstandard#334 ·
Maintainer thường phản hồi trong vòng 4 ngày
Tất cả issue của indygreg/python-zstandard
Issue tương tự
-
bug good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
enhancement
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
FujiNetWIFI/fujinet-lib#122 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 12 ngày
-
bug format I/O medium priority rt_lib
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày