Skip to content

gh-132983: Clean-ups for _zstd #133670

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

Merged
merged 16 commits into from
May 9, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
zstd: Replace _compressionLevel_values with ZSTD_CLEVEL_DEFAULT
  • Loading branch information
AA-Turner committed May 8, 2025
commit 977433844a931d0390032fb1bb380e0d15a50f1a
2 changes: 1 addition & 1 deletion Lib/compression/zstd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
ZstdCompressor, ZstdDecompressor, ZstdDict, ZstdError)
from compression.zstd._zstdfile import ZstdFile, open, _nbytes

COMPRESSION_LEVEL_DEFAULT = _zstd._compressionLevel_values[0]
COMPRESSION_LEVEL_DEFAULT = _zstd.ZSTD_CLEVEL_DEFAULT
"""The default compression level for Zstandard, currently '3'."""


Expand Down
26 changes: 10 additions & 16 deletions Modules/_zstd/_zstdmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -632,28 +632,22 @@ add_vars_to_module(PyObject *module)
}
Py_DECREF(vi);

/* Add zstd parameters */
if (add_parameters(module) < 0) {
/* ZSTD_CLEVEL_DEFAULT, int */
#if ZSTD_VERSION_NUMBER >= 10500
if (PyModule_AddIntConstant(module, "ZSTD_CLEVEL_DEFAULT",
ZSTD_defaultCLevel()) < 0) {
return -1;
}

/* _compressionLevel_values: (default, min, max)
ZSTD_defaultCLevel() was added in zstd v1.5.0 */
obj = Py_BuildValue("iii",
#if ZSTD_VERSION_NUMBER < 10500
ZSTD_CLEVEL_DEFAULT,
#else
ZSTD_defaultCLevel(),
if (PyModule_AddIntMacro(module, ZSTD_CLEVEL_DEFAULT) < 0) {
return -1;
}
#endif
ZSTD_minCLevel(),
ZSTD_maxCLevel());
if (PyModule_AddObjectRef(module,
"_compressionLevel_values",
obj) < 0) {
Py_XDECREF(obj);

/* Add zstd parameters */
if (add_parameters(module) < 0) {
return -1;
}
Py_DECREF(obj);

/* _ZSTD_CStreamSizes */
obj = Py_BuildValue("II",
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy