Visitar URL original
Add `_zstd` stdlib module backing `compression.zstd` by JamesClarke7283 · Pull Request #7962 · RustPython/RustPython · GitHub
Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
9e5c27f
Add _zstd stdlib module backing compression.zstd
JamesClarke7283 May 23, 2026
1def1b4
Fix iOS build by removing static PyMutex<PyTypeRef>
JamesClarke7283 May 23, 2026
ee26123
Fix clippy errors in zstd module
JamesClarke7283 May 23, 2026
fbce9c9
Retrigger CI
JamesClarke7283 May 23, 2026
63103b6
chore: format zstd module
JamesClarke7283 May 23, 2026
77370cb
Update crates/stdlib/src/zstd.rs
JamesClarke7283 May 24, 2026
ace862f
chore: remove rustdoc comments from zstd module
JamesClarke7283 May 24, 2026
07aa356
commit message
JamesClarke7283 May 25, 2026
f7598d6
commit message
JamesClarke7283 May 25, 2026
9b1e29e
Identify zstd parameter enums by type identity, not name
JamesClarke7283 Jun 3, 2026
e6c5b19
Match CPython error behavior in _zstd ZstdCompressor
JamesClarke7283 Jun 3, 2026
dbe4626
Address review: drop decorative separators and unused zstd crate
JamesClarke7283 Aug 9, 2026
9d497f4
Switch _zstd backend from zstd-safe to pure-Rust libzstd-rs-sys
JamesClarke7283 Aug 9, 2026
8fe59b8
Fix data loss in ZstdDecompressor.decompress(max_length=0)
JamesClarke7283 Aug 9, 2026
3d4825e
Drop duplicate spell-checker line in zstd.rs
JamesClarke7283 Aug 9, 2026
52bea59
Address review on _zstd constants, version attrs and dict markers
JamesClarke7283 Aug 19, 2026
1335148
Replace the _zstd flush-mode constants with a CompressMode enum
JamesClarke7283 Aug 19, 2026
68bed04
Correct the _zstd explanatory comments and raise MemoryError on OOM
JamesClarke7283 Aug 19, 2026
e163561
Fix CPython divergences and a crash in the _zstd module
JamesClarke7283 Aug 19, 2026
041f631
Restore Lib/test/test_zstd.py to its vendored CPython state
JamesClarke7283 Aug 19, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add _zstd stdlib module backing compression.zstd
- Implement ZstdDict, ZstdCompressor, and ZstdDecompressor on top of the zstd-safe crate
- Wire the module into stdlib_module_defs (gated off Android/wasm32)
- Mark test_zstd_multithread_compress as expected failure when libzstd lacks multi-threading support
  • Loading branch information
JamesClarke7283 committed Aug 19, 2026
commit 9e5c27f71ce30ad22558875c1fda75d82054017a
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,8 @@ x509-cert = "0.3.0"
x509-parser = "0.18"
xml = "1.3"
writeable = "0.6"
zstd = { version = "0.13", default-features = false, features = ["zdict_builder"] }
zstd-safe = { version = "7", default-features = false, features = ["zdict_builder"] }

# Lints

Expand Down
7 changes: 5 additions & 2 deletions Lib/test/test_zstd.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,11 @@ def test_unknown_compression_parameter(self):
with self.assertRaisesRegex(ValueError, pattern):
ZstdCompressor(options=option)

@unittest.skipIf(not SUPPORT_MULTITHREADING,
"zstd build doesn't support multi-threaded compression")
# TODO: RUSTPYTHON
@unittest.expectedFailureIf(
not SUPPORT_MULTITHREADING,
"TODO: RUSTPYTHON; libzstd built without multi-threaded compression support",
)
def test_zstd_multithread_compress(self):
size = 40*_1M
b = THIS_FILE_BYTES * (size // len(THIS_FILE_BYTES))
Expand Down
2 changes: 2 additions & 0 deletions crates/stdlib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ pkcs8 = { workspace = true, features = ["encryption", "pkcs5", "pem"], optional
libsqlite3-sys = { workspace = true, features = ["bundled"], optional = true }
xz = { workspace = true }
xz-sys = { workspace = true }
zstd = { workspace = true }
zstd-safe = { workspace = true }

[target.'cfg(windows)'.dependencies]
paste = { workspace = true }
Expand Down
5 changes: 5 additions & 0 deletions crates/stdlib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ mod lzma;

mod zlib;

#[cfg(not(any(target_os = "android", target_arch = "wasm32")))]
mod zstd;

mod blake2;
mod hashlib;
mod md5;
Expand Down Expand Up @@ -279,5 +282,7 @@ pub fn stdlib_module_defs(ctx: &Context) -> Vec<&'static builtins::PyModuleDef>
))]
uuid::module_def(ctx),
zlib::module_def(ctx),
#[cfg(not(any(target_os = "android", target_arch = "wasm32")))]
zstd::module_def(ctx),
]
}
Loading