Skip to content

Commit 576a52c

Browse files
committed
zstd: Replace _compressionLevel_values with ZSTD_CLEVEL_DEFAULT
1 parent 8614ad8 commit 576a52c

File tree

2 files changed

+11
-17
lines changed

2 files changed

+11
-17
lines changed

Lib/compression/zstd/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
ZstdCompressor, ZstdDecompressor, ZstdDict, ZstdError)
3333
from compression.zstd._zstdfile import ZstdFile, open, _nbytes
3434

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

3838

Modules/_zstd/_zstdmodule.c

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -632,28 +632,22 @@ add_vars_to_module(PyObject *module)
632632
}
633633
Py_DECREF(vi);
634634

635-
/* Add zstd parameters */
636-
if (add_parameters(module) < 0) {
635+
/* ZSTD_CLEVEL_DEFAULT, int */
636+
#if ZSTD_VERSION_NUMBER >= 10500
637+
if (PyModule_AddIntConstant(module, "ZSTD_CLEVEL_DEFAULT",
638+
ZSTD_defaultCLevel()) < 0) {
637639
return -1;
638640
}
639-
640-
/* _compressionLevel_values: (default, min, max)
641-
ZSTD_defaultCLevel() was added in zstd v1.5.0 */
642-
obj = Py_BuildValue("iii",
643-
#if ZSTD_VERSION_NUMBER < 10500
644-
ZSTD_CLEVEL_DEFAULT,
645641
#else
646-
ZSTD_defaultCLevel(),
642+
if (PyModule_AddIntMacro(module, ZSTD_CLEVEL_DEFAULT) < 0) {
643+
return -1;
644+
}
647645
#endif
648-
ZSTD_minCLevel(),
649-
ZSTD_maxCLevel());
650-
if (PyModule_AddObjectRef(module,
651-
"_compressionLevel_values",
652-
obj) < 0) {
653-
Py_XDECREF(obj);
646+
647+
/* Add zstd parameters */
648+
if (add_parameters(module) < 0) {
654649
return -1;
655650
}
656-
Py_DECREF(obj);
657651

658652
/* _ZSTD_CStreamSizes */
659653
obj = Py_BuildValue("II",

0 commit comments

Comments
 (0)