-
Notifications
You must be signed in to change notification settings - Fork 1.1k
PYTHON-5522: Support std lib zstandard in 3.14 #2592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Hi @Rogdham, thanks for this! Unfortunately the version of CPython we have in our CI does not yet include zstandard support, so we'll have to block this PR on getting that added to our infrastructure. I will circle back once that is complete. |
|
I opened PYTHON-5625 and blocked this ticket on that work. |
| @@ -1 +1 @@ | |||
| zstandard | |||
| backports.zstd>=1.0.0;python_version<'3.14' | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer we keep using zstandard to limit the scope of these changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Rogdham what are the benefits to using backports.zstd vs zstandard? I'd prefer to avoid changing our dependency unless there is a strong motivation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main benefit is to be sure to have the same exact API as compressor.zstd, so switching one for the other based on Python version will always work. This is guarantied because it is the exact same code as in CPython, with only the needed modifications to support older versions.
Other benefits are less clear and depends on the use cases:
- Free threading support on Python 3.13
- Wheels are smaller (e.g. for Linux 64bits on 3.13 490.8kB vs 5.5 MB)
- Adds support for Zstandard in other stdlib modules such as
tarfileorzipfile
|
After working on PYTHON-5625, we actually do support diff --git a/.evergreen/scripts/generate_config.py b/.evergreen/scripts/generate_config.py
index daec0841d..116aea77d 100644
--- a/.evergreen/scripts/generate_config.py
+++ b/.evergreen/scripts/generate_config.py
@@ -194,6 +194,22 @@ def create_compression_variants():
expansions=expansions,
)
)
+ # Add explicit tests with compression.zstd support on linux.
+ host = HOSTS["ubuntu22"]
+ expansions = dict(COMPRESSOR="ztsd")
+ tasks = [
+ ".test-standard !.server-4.2 !.server-4.4 !.server-5.0 .python-3.14",
+ ".test-standard !.server-4.2 !.server-4.4 !.server-5.0 .python-3.14t",
+ ]
+ display_name = get_variant_name(f"Compression {compressor}", host)
+ variants.append(
+ create_variant(
+ tasks,
+ display_name,
+ host=host,
+ expansions=expansions,
+ )
+ )
return variantsYou would then run |
|
Thank you for looking into this @blink1073! I think I managed to apply your suggested changes bindly 🙈 |
|
Thanks @Rogdham! Here's the result of the run:
|

Issue Key
Summary
Python 3.14 introduces support for Zstandard in the standard library via the
compression.zstdmodule (PEP-784).This PR removes the
zstdandarddependency in favor of the native support in Python 3.14+. For older Python versions, the backport is used.It also has the advantage of supporting free threading.
Full disclosure: I'm the author and maintainer of
backports.zstd, and the maintainer ofpyzstd(which code was used as a base for the integration into Python). I also helped with PEP-784 and its integration into CPython.Changes in this PR
zstandarddependency (in the extra groupzstd)backports.zstddependency for Python before 3.14 (in the extra groupzstd)Testing Plan
I tried to run the tests but fail to launch
just setup-tests, so all tests were not run.I let reviewers perform tests on both Python versions before 3.14 and 3.14.
Checklist
Checklist for Author
Checklist for Reviewer {@primary_reviewer}
Focus Areas for Reviewer (optional)