Skip to content

Commit 1b0d165

Browse files
committed
Add _zstd module
This commit introduces the `_zstd` module, with bindings to libzstd from the pyzstd project. It also includes the unix build system configuration. Windows build system support will be integrated independently as it depends on integration with cpython-source-deps.
1 parent bd2e5f0 commit 1b0d165

21 files changed

+5030
-1
lines changed

Doc/license.rst

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,3 +1132,39 @@ The file is distributed under the 2-Clause BSD License::
11321132
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
11331133
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
11341134
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1135+
1136+
1137+
Zstandard bindings
1138+
------------------
1139+
1140+
Zstandard bindings in :file:`Modules/_zstd` and :file:`Lib/zstd` are based on
1141+
code from the pyzstd library, copyright Ma Lin and contributors. The code is
1142+
distributed under the 3-Clause BSD License::
1143+
1144+
Copyright (c) 2020-present, Ma Lin and contributors.
1145+
All rights reserved.
1146+
1147+
Redistribution and use in source and binary forms, with or without
1148+
modification, are permitted provided that the following conditions are met:
1149+
1150+
1. Redistributions of source code must retain the above copyright notice, this
1151+
list of conditions and the following disclaimer.
1152+
1153+
2. Redistributions in binary form must reproduce the above copyright notice,
1154+
this list of conditions and the following disclaimer in the documentation
1155+
and/or other materials provided with the distribution.
1156+
1157+
3. Neither the name of the copyright holder nor the names of its
1158+
contributors may be used to endorse or promote products derived from
1159+
this software without specific prior written permission.
1160+
1161+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1162+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1163+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1164+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
1165+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1166+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
1167+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
1168+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
1169+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1170+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Include/internal/pycore_global_objects_fini_generated.h

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_global_strings.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ struct _Py_global_strings {
325325
STRUCT_FOR_ID(bytes_per_sep)
326326
STRUCT_FOR_ID(c_call)
327327
STRUCT_FOR_ID(c_exception)
328+
STRUCT_FOR_ID(c_parameter_type)
328329
STRUCT_FOR_ID(c_return)
329330
STRUCT_FOR_ID(cached_datetime_module)
330331
STRUCT_FOR_ID(cached_statements)
@@ -378,6 +379,7 @@ struct _Py_global_strings {
378379
STRUCT_FOR_ID(count)
379380
STRUCT_FOR_ID(covariant)
380381
STRUCT_FOR_ID(cwd)
382+
STRUCT_FOR_ID(d_parameter_type)
381383
STRUCT_FOR_ID(data)
382384
STRUCT_FOR_ID(database)
383385
STRUCT_FOR_ID(day)
@@ -392,6 +394,7 @@ struct _Py_global_strings {
392394
STRUCT_FOR_ID(deterministic)
393395
STRUCT_FOR_ID(device)
394396
STRUCT_FOR_ID(dict)
397+
STRUCT_FOR_ID(dict_content)
395398
STRUCT_FOR_ID(dictcomp)
396399
STRUCT_FOR_ID(difference_update)
397400
STRUCT_FOR_ID(digest)
@@ -457,6 +460,7 @@ struct _Py_global_strings {
457460
STRUCT_FOR_ID(follow_symlinks)
458461
STRUCT_FOR_ID(format)
459462
STRUCT_FOR_ID(format_spec)
463+
STRUCT_FOR_ID(frame_buffer)
460464
STRUCT_FOR_ID(from_param)
461465
STRUCT_FOR_ID(fromlist)
462466
STRUCT_FOR_ID(fromtimestamp)
@@ -514,6 +518,8 @@ struct _Py_global_strings {
514518
STRUCT_FOR_ID(intern)
515519
STRUCT_FOR_ID(intersection)
516520
STRUCT_FOR_ID(interval)
521+
STRUCT_FOR_ID(is_compress)
522+
STRUCT_FOR_ID(is_raw)
517523
STRUCT_FOR_ID(is_running)
518524
STRUCT_FOR_ID(is_struct)
519525
STRUCT_FOR_ID(isatty)
@@ -637,6 +643,7 @@ struct _Py_global_strings {
637643
STRUCT_FOR_ID(overlapped)
638644
STRUCT_FOR_ID(owner)
639645
STRUCT_FOR_ID(pages)
646+
STRUCT_FOR_ID(parameter)
640647
STRUCT_FOR_ID(parent)
641648
STRUCT_FOR_ID(password)
642649
STRUCT_FOR_ID(path)
@@ -798,6 +805,7 @@ struct _Py_global_strings {
798805
STRUCT_FOR_ID(write_through)
799806
STRUCT_FOR_ID(year)
800807
STRUCT_FOR_ID(zdict)
808+
STRUCT_FOR_ID(zstd_dict)
801809
} identifiers;
802810
struct {
803811
PyASCIIObject _ascii;

Include/internal/pycore_runtime_init_generated.h

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_unicodeobject_generated.h

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile.pre.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3332,6 +3332,7 @@ MODULE__TESTCAPI_DEPS=$(srcdir)/Modules/_testcapi/parts.h $(srcdir)/Modules/_tes
33323332
MODULE__TESTLIMITEDCAPI_DEPS=$(srcdir)/Modules/_testlimitedcapi/testcapi_long.h $(srcdir)/Modules/_testlimitedcapi/parts.h $(srcdir)/Modules/_testlimitedcapi/util.h
33333333
MODULE__TESTINTERNALCAPI_DEPS=$(srcdir)/Modules/_testinternalcapi/parts.h
33343334
MODULE__SQLITE3_DEPS=$(srcdir)/Modules/_sqlite/connection.h $(srcdir)/Modules/_sqlite/cursor.h $(srcdir)/Modules/_sqlite/microprotocols.h $(srcdir)/Modules/_sqlite/module.h $(srcdir)/Modules/_sqlite/prepare_protocol.h $(srcdir)/Modules/_sqlite/row.h $(srcdir)/Modules/_sqlite/util.h
3335+
MODULE__ZSTD_DEPS=$(srcdir)/Modules/_zstd/_zstdmodule.h $(srcdir)/Modules/_zstd/buffer.h
33353336

33363337
CODECS_COMMON_HEADERS=$(srcdir)/Modules/cjkcodecs/multibytecodec.h $(srcdir)/Modules/cjkcodecs/cjkcodecs.h
33373338
MODULE__CODECS_CN_DEPS=$(srcdir)/Modules/cjkcodecs/mappings_cn.h $(CODECS_COMMON_HEADERS)

Modules/Setup

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ PYTHONPATH=$(COREPYTHONPATH)
200200
#_dbm _dbmmodule.c -lgdbm_compat -DUSE_GDBM_COMPAT
201201
#_gdbm _gdbmmodule.c -lgdbm
202202
#_lzma _lzmamodule.c -llzma
203+
#_zstd _zstd/_zstdmodule.c -lzstd -I$(srcdir)/Modules/_zstd
203204
#_uuid _uuidmodule.c -luuid
204205
#zlib zlibmodule.c -lz
205206

Modules/Setup.stdlib.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,11 @@
6464
@MODULE__DECIMAL_TRUE@_decimal _decimal/_decimal.c
6565

6666
# compression libs and binascii (optional CRC32 from zlib)
67-
# bindings need -lbz2, -lz, or -llzma, respectively
67+
# bindings need -lbz2, -llzma, -lzstd, or -lz, respectively
6868
@MODULE_BINASCII_TRUE@binascii binascii.c
6969
@MODULE__BZ2_TRUE@_bz2 _bz2module.c
7070
@MODULE__LZMA_TRUE@_lzma _lzmamodule.c
71+
@MODULE__ZSTD_TRUE@_zstd _zstd/_zstdmodule.c _zstd/zdict.c _zstd/compressor.c _zstd/decompressor.c
7172
@MODULE_ZLIB_TRUE@zlib zlibmodule.c
7273

7374
# dbm/gdbm

0 commit comments

Comments
 (0)