zstd 1.5.5.1__tar.gz → 1.5.6.2__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. zstd-1.5.6.2/PKG-INFO +344 -0
  2. {zstd-1.5.5.1 → zstd-1.5.6.2}/README.rst +57 -6
  3. {zstd-1.5.5.1 → zstd-1.5.6.2}/setup.py +40 -9
  4. {zstd-1.5.5.1 → zstd-1.5.6.2}/src/python-zstd.c +74 -0
  5. {zstd-1.5.5.1 → zstd-1.5.6.2}/src/python-zstd.h +8 -1
  6. zstd-1.5.6.2/src/zstd.egg-info/PKG-INFO +344 -0
  7. {zstd-1.5.5.1 → zstd-1.5.6.2}/src/zstd.egg-info/SOURCES.txt +2 -10
  8. {zstd-1.5.5.1 → zstd-1.5.6.2}/tests/base.py +3 -3
  9. zstd-1.5.6.2/tests/test_decompress.py +24 -0
  10. zstd-1.5.6.2/tests/test_speed.py +52 -0
  11. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/common/allocations.h +1 -1
  12. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/common/bitstream.h +49 -29
  13. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/common/compiler.h +114 -22
  14. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/common/cpu.h +36 -0
  15. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/common/debug.c +6 -0
  16. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/common/debug.h +20 -11
  17. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/common/error_private.h +45 -36
  18. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/common/fse.h +3 -2
  19. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/common/fse_decompress.c +19 -17
  20. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/common/huf.h +14 -1
  21. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/common/mem.h +0 -9
  22. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/common/pool.c +1 -1
  23. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/common/pool.h +1 -1
  24. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/common/portability_macros.h +2 -0
  25. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/common/threading.c +8 -2
  26. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/common/xxhash.c +5 -11
  27. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/common/xxhash.h +2341 -1007
  28. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/common/zstd_internal.h +5 -5
  29. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/compress/fse_compress.c +8 -7
  30. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/compress/huf_compress.c +54 -25
  31. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/compress/zstd_compress.c +282 -161
  32. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/compress/zstd_compress_internal.h +29 -27
  33. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/compress/zstd_compress_superblock.c +224 -113
  34. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/compress/zstd_cwksp.h +19 -13
  35. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/compress/zstd_double_fast.c +17 -5
  36. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/compress/zstd_double_fast.h +11 -0
  37. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/compress/zstd_fast.c +14 -6
  38. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/compress/zstd_lazy.c +129 -87
  39. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/compress/zstd_lazy.h +103 -28
  40. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/compress/zstd_ldm.c +8 -2
  41. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/compress/zstd_opt.c +216 -112
  42. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/compress/zstd_opt.h +31 -7
  43. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/compress/zstdmt_compress.c +94 -79
  44. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/decompress/huf_decompress.c +188 -126
  45. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/decompress/huf_decompress_amd64.S +38 -19
  46. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/decompress/zstd_decompress.c +84 -32
  47. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/decompress/zstd_decompress_block.c +231 -208
  48. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/decompress/zstd_decompress_block.h +1 -1
  49. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/decompress/zstd_decompress_internal.h +2 -0
  50. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/legacy/zstd_legacy.h +30 -0
  51. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/legacy/zstd_v01.c +2 -0
  52. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/legacy/zstd_v02.c +4 -16
  53. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/legacy/zstd_v03.c +4 -16
  54. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/legacy/zstd_v04.c +4 -11
  55. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/legacy/zstd_v05.c +1 -0
  56. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/legacy/zstd_v06.c +2 -9
  57. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/legacy/zstd_v07.c +2 -10
  58. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/zstd.h +129 -60
  59. zstd-1.5.5.1/PKG-INFO +0 -281
  60. zstd-1.5.5.1/src/zstd.cpython-311-x86_64-linux-gnu.so +0 -0
  61. zstd-1.5.5.1/src/zstd.egg-info/PKG-INFO +0 -281
  62. zstd-1.5.5.1/src/zstd.so +0 -0
  63. zstd-1.5.5.1/tests/__init__.pyc +0 -0
  64. zstd-1.5.5.1/tests/__pycache__/__init__.cpython-311.pyc +0 -0
  65. zstd-1.5.5.1/tests/__pycache__/base.cpython-311.pyc +0 -0
  66. zstd-1.5.5.1/tests/__pycache__/test_compress.cpython-311.pyc +0 -0
  67. zstd-1.5.5.1/tests/__pycache__/test_version.cpython-311.pyc +0 -0
  68. zstd-1.5.5.1/tests/base.pyc +0 -0
  69. zstd-1.5.5.1/tests/test_compress.pyc +0 -0
  70. zstd-1.5.5.1/tests/test_version.pyc +0 -0
  71. {zstd-1.5.5.1 → zstd-1.5.6.2}/LICENSE +0 -0
  72. {zstd-1.5.5.1 → zstd-1.5.6.2}/MANIFEST.in +0 -0
  73. {zstd-1.5.5.1 → zstd-1.5.6.2}/setup.cfg +0 -0
  74. {zstd-1.5.5.1 → zstd-1.5.6.2}/src/pythoncapi_compat.h +0 -0
  75. {zstd-1.5.5.1 → zstd-1.5.6.2}/src/util.c +0 -0
  76. {zstd-1.5.5.1 → zstd-1.5.6.2}/src/util.h +0 -0
  77. {zstd-1.5.5.1 → zstd-1.5.6.2}/src/zstd.egg-info/dependency_links.txt +0 -0
  78. {zstd-1.5.5.1 → zstd-1.5.6.2}/src/zstd.egg-info/top_level.txt +0 -0
  79. {zstd-1.5.5.1 → zstd-1.5.6.2}/tests/__init__.py +0 -0
  80. {zstd-1.5.5.1 → zstd-1.5.6.2}/tests/test_compress.py +0 -0
  81. {zstd-1.5.5.1 → zstd-1.5.6.2}/tests/test_version.py +0 -0
  82. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/common/bits.h +0 -0
  83. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/common/entropy_common.c +0 -0
  84. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/common/error_private.c +0 -0
  85. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/common/threading.h +0 -0
  86. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/common/zstd_common.c +0 -0
  87. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/common/zstd_deps.h +0 -0
  88. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/common/zstd_trace.h +0 -0
  89. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/compress/clevels.h +0 -0
  90. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/compress/hist.c +0 -0
  91. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/compress/hist.h +0 -0
  92. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/compress/zstd_compress_literals.c +0 -0
  93. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/compress/zstd_compress_literals.h +0 -0
  94. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/compress/zstd_compress_sequences.c +0 -0
  95. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/compress/zstd_compress_sequences.h +0 -0
  96. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/compress/zstd_compress_superblock.h +0 -0
  97. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/compress/zstd_fast.h +0 -0
  98. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/compress/zstd_ldm.h +0 -0
  99. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/compress/zstd_ldm_geartab.h +0 -0
  100. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/compress/zstdmt_compress.h +0 -0
  101. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/decompress/zstd_ddict.c +0 -0
  102. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/decompress/zstd_ddict.h +0 -0
  103. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/legacy/zstd_v01.h +0 -0
  104. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/legacy/zstd_v02.h +0 -0
  105. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/legacy/zstd_v03.h +0 -0
  106. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/legacy/zstd_v04.h +0 -0
  107. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/legacy/zstd_v05.h +0 -0
  108. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/legacy/zstd_v06.h +0 -0
  109. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/legacy/zstd_v07.h +0 -0
  110. {zstd-1.5.5.1 → zstd-1.5.6.2}/zstd/lib/zstd_errors.h +0 -0
zstd-1.5.6.2/PKG-INFO ADDED
@@ -0,0 +1,344 @@
1
+ Metadata-Version: 2.2
2
+ Name: zstd
3
+ Version: 1.5.6.2
4
+ Summary: ZSTD Bindings for Python
5
+ Home-page: https://github.com/sergey-dryabzhinsky/python-zstd
6
+ Author: Sergey Dryabzhinsky, Anton Stuk
7
+ Author-email: sergey.dryabzhinsky@gmail.com
8
+ Maintainer: Sergey Dryabzhinsky
9
+ Maintainer-email: sergey.dryabzhinsky@gmail.com
10
+ License: BSD
11
+ Keywords: zstd,zstandard,compression
12
+ Classifier: License :: OSI Approved :: BSD License
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Development Status :: 5 - Production/Stable
15
+ Classifier: Operating System :: POSIX
16
+ Classifier: Programming Language :: C
17
+ Classifier: Programming Language :: Python
18
+ Classifier: Programming Language :: Python :: 2.7
19
+ Classifier: Programming Language :: Python :: 3.4
20
+ Classifier: Programming Language :: Python :: 3.5
21
+ Classifier: Programming Language :: Python :: 3.6
22
+ Classifier: Programming Language :: Python :: 3.7
23
+ Classifier: Programming Language :: Python :: 3.8
24
+ Classifier: Programming Language :: Python :: 3.9
25
+ Classifier: Programming Language :: Python :: 3.10
26
+ Classifier: Programming Language :: Python :: 3.11
27
+ Classifier: Programming Language :: Python :: 3.12
28
+ Classifier: Programming Language :: Python :: 3.13
29
+ License-File: LICENSE
30
+ Dynamic: author
31
+ Dynamic: author-email
32
+ Dynamic: classifier
33
+ Dynamic: description
34
+ Dynamic: home-page
35
+ Dynamic: keywords
36
+ Dynamic: license
37
+ Dynamic: maintainer
38
+ Dynamic: maintainer-email
39
+ Dynamic: summary
40
+
41
+ 7=============
42
+ python-zstd
43
+ =============
44
+
45
+ .. |releaseW| image:: https://github.com/sergey-dryabzhinsky/python-zstd/actions/workflows/build-wheels.yml/badge.svg?branch=v1.5.6.2
46
+ :target: https://github.com/sergey-dryabzhinsky/python-zstd/actions/workflows/build-wheels.yml
47
+
48
+ .. |masterW| image:: https://github.com/sergey-dryabzhinsky/python-zstd/actions/workflows/build-wheels.yml/badge.svg
49
+ :target: https://github.com/sergey-dryabzhinsky/python-zstd/actions/workflows/build-wheels.yml
50
+
51
+ +---------+------------+
52
+ | branch | status |
53
+ +=========+============+
54
+ | Release | |releaseW| |
55
+ +---------+------------+
56
+ | Master | |masterW| |
57
+ +---------+------------+
58
+
59
+ Simple python bindings to Yann Collet ZSTD compression library.
60
+
61
+ **Zstd**, short for Zstandard, is a new lossless compression algorithm,
62
+ which provides both good compression ratio *and* speed for your standard compression needs.
63
+ "Standard" translates into everyday situations which neither look for highest possible ratio
64
+ (which LZMA and ZPAQ cover) nor extreme speeds (which LZ4 covers).
65
+
66
+ It is provided as a BSD-license package, hosted on GitHub_.
67
+
68
+ .. _GitHub: https://github.com/facebook/zstd
69
+
70
+
71
+ WARNING!!!
72
+ ----------
73
+
74
+ If you setup 1.0.0.99.1 version - remove it manualy to able to update.
75
+ PIP matching version strings not tuple of numbers.
76
+
77
+ Result generated by versions prior to 1.0.0.99.1 is not compatible with orignial Zstd
78
+ by any means. It generates custom header and can be read only by zstd python module.
79
+
80
+ As of 1.0.0.99.1 version it uses standard Zstd output, not modified.
81
+
82
+ To prevent data loss there is two functions now: ```compress_old``` and ```decompress_old```.
83
+ They are works just like in old versions prior to 1.0.0.99.1.
84
+
85
+ As of 1.1.4 version module build without them by default.
86
+
87
+ As of 1.3.4 version these functions are deprecated and will be removed in future releases.
88
+
89
+ As of 1.5.0 version these functions are removed.
90
+
91
+
92
+ DISCLAIMER
93
+ __________
94
+
95
+ These python bindings are kept simple and blunt.
96
+
97
+ Support of dictionaries and streaming is not planned.
98
+
99
+
100
+ LINKS
101
+ -----
102
+
103
+ * Zstandard: https://github.com/facebook/zstd
104
+ * More full-featured and compatible with Zstandard python bindings by Gregory Szorc: https://github.com/indygreg/python-zstandard
105
+
106
+
107
+ Build from source
108
+ -----------------
109
+
110
+ >>> $ git clone https://github.com/sergey-dryabzhinsky/python-zstd
111
+ >>> $ git submodule update --init
112
+ >>> $ apt-get install python-dev python3-dev python-setuptools python3-setuptools
113
+ >>> $ python setup.py build_ext clean
114
+ >>> $ python3 setup.py build_ext clean
115
+
116
+ Note: Zstd legacy format support disabled by default.
117
+ To build with Zstd legacy versions support - pass ``--legacy`` option to setup.py script:
118
+
119
+ >>> $ python setup.py build_ext --legacy clean
120
+
121
+ When using a PEP 517 builder you can use ``ZSTD_LEGACY`` environment variable instead:
122
+
123
+ >>> $ ZSTD_LEGACY=1 python -m build -w
124
+
125
+ Note: Python-Zstd legacy format support removed since 1.5.0.
126
+ If you need to convert old data - checkout 1.4.9.1 module version. Support of it disabled by default.
127
+ To build with python-zstd legacy format support (pre 1.1.2) - pass ``--pyzstd-legacy`` option to setup.py script:
128
+
129
+ >>> $ python setup.py build_ext --pyzstd-legacy clean
130
+
131
+ But beware! Legacy formats support state is unknown in this case.
132
+ And if your version not equal with python-zstd - tests may not pass.
133
+
134
+ If you're scared of threads you may pass option `--libzstd-no-threads`:
135
+
136
+ >>> $ python setup.py build_ext --libzstd-no-threads clean
137
+
138
+ When using a PEP 517 builder you can use ``ZSTD_THREADS`` environment variable instead:
139
+
140
+ >>> $ ZSTD_THREADS=0 python -m build -w
141
+
142
+ If you're meet some cpu instruction errorrs you may try to disable built-in optimizations and pass option `--libzstd-no-use-asm`:
143
+
144
+ >>> $ python setup.py build_ext --libzstd-no-use-asm clean
145
+
146
+ Or add more speed with option `--libzstd-use-asm-bmi2` to use instructions for new AMD CPU.
147
+ When using a PEP 517 builder you can use ``ZSTD_ASM`` environment variable instead:
148
+ And ``ZST_ASM_BMI2=1`` too for bmi2 use.
149
+
150
+ >>> $ ZSTD_ASM=0 python -m build -w
151
+
152
+
153
+ If you want to build with existing distribution of libzstd just add ``--external`` option
154
+
155
+ >>> $ python setup.py build_ext --external clean
156
+
157
+ When using a PEP 517 builder you can use ``ZSTD_EXTERNAL`` environment variable instead:
158
+
159
+ >>> $ ZSTD_EXTERNAL=1 python -m build -w
160
+
161
+ If paths to header file ``zstd.h`` and libraries is uncommon - use common ``build`` params:
162
+ --libraries --include-dirs --library-dirs.
163
+
164
+ >>> $ python setup.py build_ext --external --include-dirs /opt/zstd/usr/include --libraries zstd --library-dirs /opt/zstd/lib clean
165
+
166
+
167
+ Install from pypi
168
+ -----------------
169
+
170
+ >>> # for Python 2.7+
171
+ >>> $ pip install zstd
172
+ >>> # or for Python 3.4+
173
+ >>> $ pip3 install zstd
174
+
175
+
176
+ API
177
+ ___
178
+
179
+ Error
180
+ Standard python Exception for zstd module
181
+
182
+ ZSTD_compress (data[, level, threads]): string|bytes
183
+ Function, compress input data block via mutliple threads, return compressed block, or raises Error.
184
+
185
+ Params:
186
+
187
+ * **data**: string|bytes - input data block, length limited by 2Gb by Python API
188
+ * **level**: int - compression level, ultra-fast levels from -100 (ultra) to -1 (fast) available since zstd-1.3.4, and from 1 (fast) to 22 (slowest), 0 or unset - means default (3). Default - 3.
189
+ * **threads**: int - how many threads to use, from 0 to 200, 0 or unset - auto-tune by cpu cores count. Default - 0. Since: 1.4.4.1
190
+
191
+ Aliases:
192
+ - *compress(...)*,
193
+ - *dumps(...)*,
194
+ - *encode(...)* since: 1.5.6.2
195
+
196
+ Exception if:
197
+ - level bigger than max level
198
+
199
+ Max number of threads:
200
+ - 32bit system: 64
201
+ - 64bit system: 256
202
+ If provided bigger number - silently set maximber (since 1.5.4.1)
203
+
204
+ Since: 0.1
205
+
206
+ ZSTD_uncompress (data): string|bytes
207
+ Function, decompress input compressed data block, return decompressed block, or raises Error.
208
+
209
+ Support compressed data with multiple/concatenated frames (blocks) (since 1.5.5.1).
210
+
211
+ Params:
212
+
213
+ * **data**: string|bytes - input compressed data block, length limited by 2Gb by Python API
214
+
215
+ Aliases:
216
+ - *decompress(...)*,
217
+ - *uncompress(...)*,
218
+ - *loads(...)*,
219
+ - *decode(...)* since: 1.5.6.2
220
+
221
+ Since: 0.1
222
+
223
+ ZSTD_check (data): string|bytes
224
+ Function, checks if input is zstd compressed data block, return s1if yes, 0 if no, or raises Error.
225
+
226
+ Support compressed data with multiple/concatenated frames (blocks) .
227
+
228
+ Params:
229
+
230
+ * **data**: string|bytes - input compressed data block, length limited by 2Gb by Python API
231
+
232
+ Aliases:
233
+ - *check(...)*,
234
+
235
+ Since: 1.5.6.2
236
+
237
+ version (): string|bytes
238
+ Returns this module doted version string.
239
+
240
+ The first three digits are folow libzstd version.
241
+ Fourth digit - module release number for that version.
242
+
243
+ Since: 1.3.4.3
244
+
245
+ ZSTD_version (): string|bytes
246
+ Returns ZSTD library doted version string.
247
+
248
+ Since: 1.3.4.3
249
+
250
+ ZSTD_version_number (): int
251
+ Returns ZSTD library version in format: MAJOR*100*100 + MINOR*100 + RELEASE.
252
+
253
+ Since: 1.3.4.3
254
+
255
+ ZSTD_threads_count (): int
256
+ Returns ZSTD determined CPU cores count.
257
+
258
+ Since: 1.5.4.1
259
+
260
+ ZSTD_max_threads_count (): int
261
+ Returns ZSTD library determined maximum working threads count.
262
+
263
+ Since: 1.5.4.1
264
+
265
+ ZSTD_external (): int
266
+ Returns 0 of 1 if ZSTD library build as external.
267
+
268
+ Since: 1.5.0.2
269
+
270
+ ZSTD_with_threads (): int
271
+ Returns 0 of 1 if bundled ZSTD library build with threads support.
272
+
273
+ Since: 1.5.6.2
274
+
275
+ ZSTD_with_asm (): int
276
+ Returns 0 of 1 if bundled ZSTD library build with asm optimization s.
277
+
278
+ Since: 1.5.6.2
279
+
280
+
281
+ Removed
282
+ _______
283
+
284
+ ZSTD_compress_old (data[, level]): string|bytes
285
+ Function, compress input data block, return compressed block, or raises Error.
286
+
287
+ **DEPRECATED**: Returns not compatible with ZSTD block header
288
+
289
+ **REMOVED**: since 1.5.0
290
+
291
+ Params:
292
+
293
+ * **data**: string|bytes - input data block, length limited by 2Gb by Python API
294
+ * **level**: int - compression level, ultra-fast levels from -5 (ultra) to -1 (fast) available since zstd-1.3.4, and from 1 (fast) to 22 (slowest), 0 or unset - means default (3). Default - 3.
295
+
296
+ Since: 1.0.0.99.1
297
+
298
+ ZSTD_uncompress_old (data): string|bytes
299
+ Function, decompress input compressed data block, return decompressed block, or raises Error.
300
+
301
+ **DEPRECATED**: Accepts data with not compatible with ZSTD block header
302
+
303
+ **REMOVED**: since 1.5.0
304
+
305
+ Params:
306
+
307
+ * **data**: string|bytes - input compressed data block, length limited by 2Gb by Python API
308
+
309
+ Since: 1.0.0.99.1
310
+
311
+ Use
312
+ ___
313
+
314
+ Module has simple API:
315
+
316
+ >>> import zstd
317
+ >>> dir(zstd)
318
+ ['Error', 'ZSTD_compress', 'ZSTD_external', 'ZSTD_uncompress', 'ZSTD_version', 'ZSTD_version_number', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'compress', 'decompress', 'dumps', 'loads', 'uncompress', 'version']
319
+ >>> zstd.version()
320
+ '1.5.1.0'
321
+ >>> zstd.ZSTD_version()
322
+ '1.5.1'
323
+ >>> zstd.ZSTD_version_number()
324
+ 10501
325
+ >>> zstd.ZSTD_external()
326
+ 0
327
+
328
+ In python2
329
+
330
+ >>> data = "123456qwert"
331
+
332
+ In python3 use bytes
333
+
334
+ >>> data = b"123456qwert"
335
+
336
+
337
+ >>> cdata = zstd.compress(data, 1)
338
+ >>> data == zstd.decompress(cdata)
339
+ True
340
+ >>> cdata_mt = zstd.compress(data, 1, 4)
341
+ >>> cdata == cdata_mt
342
+ True
343
+ >>> data == zstd.decompress(cdata_mt)
344
+ True
@@ -1,8 +1,8 @@
1
- =============
1
+ 7=============
2
2
  python-zstd
3
3
  =============
4
4
 
5
- .. |releaseW| image:: https://github.com/sergey-dryabzhinsky/python-zstd/actions/workflows/build-wheels.yml/badge.svg?branch=v1.5.5.1
5
+ .. |releaseW| image:: https://github.com/sergey-dryabzhinsky/python-zstd/actions/workflows/build-wheels.yml/badge.svg?branch=v1.5.6.2
6
6
  :target: https://github.com/sergey-dryabzhinsky/python-zstd/actions/workflows/build-wheels.yml
7
7
 
8
8
  .. |masterW| image:: https://github.com/sergey-dryabzhinsky/python-zstd/actions/workflows/build-wheels.yml/badge.svg
@@ -88,10 +88,30 @@ To build with python-zstd legacy format support (pre 1.1.2) - pass ``--pyzstd-le
88
88
 
89
89
  >>> $ python setup.py build_ext --pyzstd-legacy clean
90
90
 
91
- If you want to build with existing distribution of libzstd just add ``--external`` option.
92
91
  But beware! Legacy formats support state is unknown in this case.
93
92
  And if your version not equal with python-zstd - tests may not pass.
94
93
 
94
+ If you're scared of threads you may pass option `--libzstd-no-threads`:
95
+
96
+ >>> $ python setup.py build_ext --libzstd-no-threads clean
97
+
98
+ When using a PEP 517 builder you can use ``ZSTD_THREADS`` environment variable instead:
99
+
100
+ >>> $ ZSTD_THREADS=0 python -m build -w
101
+
102
+ If you're meet some cpu instruction errorrs you may try to disable built-in optimizations and pass option `--libzstd-no-use-asm`:
103
+
104
+ >>> $ python setup.py build_ext --libzstd-no-use-asm clean
105
+
106
+ Or add more speed with option `--libzstd-use-asm-bmi2` to use instructions for new AMD CPU.
107
+ When using a PEP 517 builder you can use ``ZSTD_ASM`` environment variable instead:
108
+ And ``ZST_ASM_BMI2=1`` too for bmi2 use.
109
+
110
+ >>> $ ZSTD_ASM=0 python -m build -w
111
+
112
+
113
+ If you want to build with existing distribution of libzstd just add ``--external`` option
114
+
95
115
  >>> $ python setup.py build_ext --external clean
96
116
 
97
117
  When using a PEP 517 builder you can use ``ZSTD_EXTERNAL`` environment variable instead:
@@ -128,7 +148,10 @@ ZSTD_compress (data[, level, threads]): string|bytes
128
148
  * **level**: int - compression level, ultra-fast levels from -100 (ultra) to -1 (fast) available since zstd-1.3.4, and from 1 (fast) to 22 (slowest), 0 or unset - means default (3). Default - 3.
129
149
  * **threads**: int - how many threads to use, from 0 to 200, 0 or unset - auto-tune by cpu cores count. Default - 0. Since: 1.4.4.1
130
150
 
131
- Aliases: *compress(...)*, *dumps(...)*
151
+ Aliases:
152
+ - *compress(...)*,
153
+ - *dumps(...)*,
154
+ - *encode(...)* since: 1.5.6.2
132
155
 
133
156
  Exception if:
134
157
  - level bigger than max level
@@ -136,7 +159,7 @@ ZSTD_compress (data[, level, threads]): string|bytes
136
159
  Max number of threads:
137
160
  - 32bit system: 64
138
161
  - 64bit system: 256
139
- If provided bigger number - silemtly set maximum number (since 1.5.4.1)
162
+ If provided bigger number - silently set maximber (since 1.5.4.1)
140
163
 
141
164
  Since: 0.1
142
165
 
@@ -149,10 +172,28 @@ ZSTD_uncompress (data): string|bytes
149
172
 
150
173
  * **data**: string|bytes - input compressed data block, length limited by 2Gb by Python API
151
174
 
152
- Aliases: *decompress(...)*, *uncompress(...)*, *loads(...)*
175
+ Aliases:
176
+ - *decompress(...)*,
177
+ - *uncompress(...)*,
178
+ - *loads(...)*,
179
+ - *decode(...)* since: 1.5.6.2
153
180
 
154
181
  Since: 0.1
155
182
 
183
+ ZSTD_check (data): string|bytes
184
+ Function, checks if input is zstd compressed data block, return s1if yes, 0 if no, or raises Error.
185
+
186
+ Support compressed data with multiple/concatenated frames (blocks) .
187
+
188
+ Params:
189
+
190
+ * **data**: string|bytes - input compressed data block, length limited by 2Gb by Python API
191
+
192
+ Aliases:
193
+ - *check(...)*,
194
+
195
+ Since: 1.5.6.2
196
+
156
197
  version (): string|bytes
157
198
  Returns this module doted version string.
158
199
 
@@ -186,6 +227,16 @@ ZSTD_external (): int
186
227
 
187
228
  Since: 1.5.0.2
188
229
 
230
+ ZSTD_with_threads (): int
231
+ Returns 0 of 1 if bundled ZSTD library build with threads support.
232
+
233
+ Since: 1.5.6.2
234
+
235
+ ZSTD_with_asm (): int
236
+ Returns 0 of 1 if bundled ZSTD library build with asm optimization s.
237
+
238
+ Since: 1.5.6.2
239
+
189
240
 
190
241
  Removed
191
242
  _______
@@ -8,13 +8,13 @@ from setuptools import setup, find_packages, Extension
8
8
  from setuptools.command.build_ext import build_ext
9
9
 
10
10
  # ZSTD version
11
- VERSION = (1, 5, 5,)
11
+ VERSION = (1, 5, 6,)
12
12
  VERSION_STR = ".".join([str(x) for x in VERSION])
13
13
 
14
14
  # Package version
15
15
  PKG_VERSION = VERSION
16
16
  # Minor versions
17
- PKG_VERSION += ("1",)
17
+ PKG_VERSION += ("2",)
18
18
  PKG_VERSION_STR = ".".join([str(x) for x in PKG_VERSION])
19
19
 
20
20
  ###
@@ -27,6 +27,35 @@ if "--legacy" in sys.argv:
27
27
  SUP_LEGACY=True
28
28
  sys.argv.remove("--legacy")
29
29
 
30
+ SUP_ASM="ZSTD_ASM" in os.environ or True
31
+ #a asm on by default
32
+ if "--libzstd-no-use-asm" in sys.argv:
33
+ # Support assembler builtin optimization in lizstd
34
+ SUP_ASM=False
35
+ sys.argv.remove("--libzstd-no-use-asm")
36
+ DISABLE_ASM=1
37
+ if SUP_ASM:
38
+ DISABLE_ASM=0
39
+
40
+ SUP_THREADS="ZSTD_THREADS" in os.environ or True
41
+ # threads on by default
42
+ if "--libzstd-no-threads" in sys.argv:
43
+ # Disable support multithreading in lizstd
44
+ SUP_THREADS=False
45
+ sys.argv.remove("--libzstd-no-threads")
46
+ ENABLE_THREADS=0
47
+ if SUP_THREADS:
48
+ ENABLE_THREADS=1
49
+
50
+ SUP_ASM_BMI2="ZSTD_ASM_BMI2" in os.environ
51
+ if "--libzstd-use-asm-bmi2" in sys.argv:
52
+ # Support assembler builtin optimization in lizstd for new AMD CPU
53
+ SUP_ASM_BMI2=True
54
+ sys.argv.remove("--libzstd-use-asm-bmi2")
55
+ ENABLE_ASM_BMI2=0
56
+ if SUP_ASM_BMI2:
57
+ ENABLE_ASM_BMI2=1
58
+
30
59
  SUP_TRACE="ZSTD_TRACE" in os.environ
31
60
  if "--debug-trace" in sys.argv:
32
61
  # Support tracing for debug
@@ -68,21 +97,21 @@ if SUP_EXTERNAL:
68
97
  # DZSTD_DISABLE_ASM=1 - disable ASM inlines, pypi/pip can't build them
69
98
  #
70
99
  COPT = {
71
- 'msvc': [ '/Ox', '/DVERSION=%s' % PKG_VERSION_STR, '/DDYNAMIC_BMI2=0', '/DZSTD_DISABLE_ASM=1' ],
72
- 'mingw32': [ '-O2', '-DVERSION=%s' % PKG_VERSION_STR, '-DDYNAMIC_BMI2=0', '-DZSTD_DISABLE_ASM=1' ],
73
- 'unix': [ '-O2', '-DVERSION=%s' % PKG_VERSION_STR, '-DDYNAMIC_BMI2=0', '-DZSTD_DISABLE_ASM=1' ],
74
- 'clang': [ '-O2', '-DVERSION=%s' % PKG_VERSION_STR, '-DDYNAMIC_BMI2=0', '-DZSTD_DISABLE_ASM=1' ],
75
- 'gcc': [ '-O2', '-DVERSION=%s' % PKG_VERSION_STR, '-DDYNAMIC_BMI2=0', '-DZSTD_DISABLE_ASM=1' ]
100
+ 'msvc': [ '/Ox', '/DVERSION=%s' % PKG_VERSION_STR, '/DDYNAMIC_BMI2=%d' % ENABLE_ASM_BMI2, '/DZSTD_DISABLE_ASM=%d' % DISABLE_ASM ],
101
+ 'mingw32': [ '-O2', '-DVERSION=%s' % PKG_VERSION_STR, '-DDYNAMIC_BMI2=%d' % ENABLE_ASM_BMI2, '-DZSTD_DISABLE_ASM=%d' % DISABLE_ASM ],
102
+ 'unix': [ '-O2', '-DVERSION=%s' % PKG_VERSION_STR, '-DDYNAMIC_BMI2=%d' % ENABLE_ASM_BMI2, '-DZSTD_DISABLE_ASM=%d' % DISABLE_ASM ],
103
+ 'clang': [ '-O2', '-DVERSION=%s' % PKG_VERSION_STR, '-DDYNAMIC_BMI2=%d' % ENABLE_ASM_BMI2, '-DZSTD_DISABLE_ASM=%d' % DISABLE_ASM ],
104
+ 'gcc': [ '-O2', '-DVERSION=%s' % PKG_VERSION_STR, '-DDYNAMIC_BMI2=%d' % ENABLE_ASM_BMI2, '-DZSTD_DISABLE_ASM=%d' % DISABLE_ASM ]
76
105
  }
77
106
 
78
107
  if not SUP_EXTERNAL:
79
108
  for comp in COPT:
80
109
  if comp == 'msvc':
81
- COPT[comp].extend([ '/DZSTD_MULTITHREAD=1',
110
+ COPT[comp].extend([ '/DZSTD_MULTITHREAD=%d' % ENABLE_THREADS,
82
111
  '/Izstd\\lib', '/Izstd\\lib\\common', '/Izstd\\lib\\compress', '/Izstd\\lib\\decompress',
83
112
  ])
84
113
  else:
85
- COPT[comp].extend([ '-DZSTD_MULTITHREAD=1',
114
+ COPT[comp].extend([ '-DZSTD_MULTITHREAD=%d' % ENABLE_THREADS,
86
115
  '-Izstd/lib', '-Izstd/lib/common', '-Izstd/lib/compress', '-Izstd/lib/decompress',
87
116
  ])
88
117
  else:
@@ -218,5 +247,7 @@ setup(
218
247
  'Programming Language :: Python :: 3.9',
219
248
  'Programming Language :: Python :: 3.10',
220
249
  'Programming Language :: Python :: 3.11',
250
+ 'Programming Language :: Python :: 3.12',
251
+ 'Programming Language :: Python :: 3.13',
221
252
  ]
222
253
  )
@@ -196,6 +196,8 @@ static PyObject *py_zstd_uncompress(PyObject* self, PyObject *args)
196
196
  PyErr_Format(ZstdError, "Decompression error: length mismatch -> decomp %lu != %lu [header]", (uint64_t)cSize, dest_size);
197
197
  error = 1;
198
198
  }
199
+ } else {
200
+ error = 1;
199
201
  }
200
202
 
201
203
  if (error) {
@@ -210,6 +212,53 @@ static PyObject *py_zstd_uncompress(PyObject* self, PyObject *args)
210
212
  return result;
211
213
  }
212
214
 
215
+ /**
216
+ * New more interoperable function
217
+ * Uses origin zstd header, nothing more
218
+ * Simple version: check if data block has zstd compressed data inside
219
+ */
220
+ static PyObject *py_zstd_check(PyObject* self, PyObject *args)
221
+ {
222
+ //PyObject *result;
223
+ const char *source, *src;
224
+ Py_ssize_t source_size, ss, seek_frame;
225
+ uint64_t dest_size, frame_size;
226
+ //char error = 0;
227
+ //size_t cSize;
228
+
229
+ #if PY_MAJOR_VERSION >= 3
230
+ if (!PyArg_ParseTuple(args, "y#", &source, &source_size))
231
+ return NULL;
232
+ #else
233
+ if (!PyArg_ParseTuple(args, "s#", &source, &source_size))
234
+ return NULL;
235
+ #endif
236
+
237
+ dest_size = (uint64_t) ZSTD_getFrameContentSize(source, source_size);
238
+ if (dest_size == ZSTD_CONTENTSIZE_UNKNOWN || dest_size == ZSTD_CONTENTSIZE_ERROR) {
239
+ //PyErr_Format(ZstdError, "Input data invalid or missing content size in frame header.");
240
+ return Py_BuildValue("i", 0);
241
+ }
242
+
243
+ // Find real dest_size across multiple frames
244
+ ss = source_size;
245
+ seek_frame = ss - 1;
246
+ src = source;
247
+ while (seek_frame < ss) {
248
+ seek_frame = ZSTD_findFrameCompressedSize(src, ss);
249
+ if (ZSTD_isError(seek_frame)) break;
250
+ src += seek_frame;
251
+ ss -= seek_frame;
252
+ if (ss <=0) break;
253
+ frame_size = (uint64_t) ZSTD_getFrameContentSize(src, ss);
254
+ if (ZSTD_isError(frame_size)) break;
255
+ dest_size += frame_size;
256
+ }
257
+ if (dest_size>=source_size)
258
+ Py_BuildValue("i", 0);
259
+ return Py_BuildValue("i", 1);
260
+ }
261
+
213
262
  /**
214
263
  * Returns this module version as string
215
264
  */
@@ -251,6 +300,25 @@ static PyObject *py_zstd_library_external(PyObject* self, PyObject *args)
251
300
  }
252
301
 
253
302
 
303
+ /**
304
+ * Returns 0 or 1 if ZSTD library build with threads
305
+ */
306
+ static PyObject *py_zstd_with_threads(PyObject* self, PyObject *args)
307
+ {
308
+ return Py_BuildValue("i", ZSTD_MULTITHREAD);
309
+ }
310
+
311
+
312
+ /**
313
+ * Returns 0 or 1 if ZSTD library build with threads
314
+ */
315
+ static PyObject *py_zstd_with_asm(PyObject* self, PyObject *args)
316
+ {
317
+ return Py_BuildValue("i", ! ZSTD_DISABLE_ASM);
318
+ }
319
+
320
+
321
+
254
322
  /**
255
323
  * Returns ZSTD determined threads count, int
256
324
  */
@@ -273,8 +341,12 @@ static PyObject *py_zstd_max_threads_count(PyObject* self, PyObject *args)
273
341
  static PyMethodDef ZstdMethods[] = {
274
342
  {"ZSTD_compress", py_zstd_compress_mt, METH_VARARGS, COMPRESS_DOCSTRING},
275
343
  {"ZSTD_uncompress", py_zstd_uncompress, METH_VARARGS, UNCOMPRESS_DOCSTRING},
344
+ {"ZSTD_check", py_zstd_check, METH_VARARGS, CHECK_DOCSTRING},
345
+ {"check", py_zstd_check, METH_VARARGS, CHECK_DOCSTRING},
276
346
  {"compress", py_zstd_compress_mt, METH_VARARGS, COMPRESS_DOCSTRING},
277
347
  {"uncompress", py_zstd_uncompress, METH_VARARGS, UNCOMPRESS_DOCSTRING},
348
+ {"encode", py_zstd_compress_mt, METH_VARARGS, COMPRESS_DOCSTRING},
349
+ {"decode", py_zstd_uncompress, METH_VARARGS, UNCOMPRESS_DOCSTRING},
278
350
  {"decompress", py_zstd_uncompress, METH_VARARGS, UNCOMPRESS_DOCSTRING},
279
351
  {"dumps", py_zstd_compress_mt, METH_VARARGS, COMPRESS_DOCSTRING},
280
352
  {"loads", py_zstd_uncompress, METH_VARARGS, UNCOMPRESS_DOCSTRING},
@@ -284,6 +356,8 @@ static PyMethodDef ZstdMethods[] = {
284
356
  {"ZSTD_threads_count", py_zstd_threads_count, METH_NOARGS, ZSTD_THREADS_COUNT_DOCSTRING},
285
357
  {"ZSTD_max_threads_count", py_zstd_max_threads_count, METH_NOARGS, ZSTD_MAX_THREADS_COUNT_DOCSTRING},
286
358
  {"ZSTD_external", py_zstd_library_external, METH_NOARGS, ZSTD_EXTERNAL_DOCSTRING},
359
+ {"ZSTD_with_threads", py_zstd_with_threads, METH_NOARGS, ZSTD_WITH_THREADS_DOCSTRING},
360
+ {"ZSTD_with_asm", py_zstd_with_asm, METH_NOARGS, ZSTD_WITH_ASM_DOCSTRING},
287
361
  {NULL, NULL, 0, NULL}
288
362
  };
289
363
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2015-2020 Sergey Dryabzhinsky
2
+ * Copyright (c) 2015-2025 Sergey Dryabzhinsky
3
3
  * All rights reserved.
4
4
  *
5
5
  * Redistribution and use in source and binary forms, with or without
@@ -80,10 +80,13 @@ static PyObject *ZstdError;
80
80
 
81
81
  static PyObject *py_zstd_compress_mt(PyObject* self, PyObject *args);
82
82
  static PyObject *py_zstd_uncompress(PyObject* self, PyObject *args);
83
+ static PyObject *py_zstd_check(PyObject* self, PyObject *args);
83
84
  static PyObject *py_zstd_module_version(PyObject* self, PyObject *args);
84
85
  static PyObject *py_zstd_library_version(PyObject* self, PyObject *args);
85
86
  static PyObject *py_zstd_library_version_int(PyObject* self, PyObject *args);
86
87
  static PyObject *py_zstd_library_external(PyObject* self, PyObject *args);
88
+ static PyObject *py_zstd_with_threads(PyObject* self, PyObject *args);
89
+ static PyObject *py_zstd_with_asm(PyObject* self, PyObject *args);
87
90
 
88
91
  #if PY_MAJOR_VERSION < 3
89
92
  PyMODINIT_FUNC initzstd(void);
@@ -104,10 +107,14 @@ Raises a zstd.Error exception if any error occurs."
104
107
 
105
108
  #define UNCOMPRESS_DOCSTRING "decompress("PY_BYTESTR_TYPE"): string -- Returns uncompressed string.\n\nRaises a zstd.Error exception if any error occurs."
106
109
 
110
+ #define CHECK_DOCSTRING "check("PY_BYTESTR_TYPE"): string -- Returns 0 or 1.\n\nRaises a zstd.Error exception if any error occurs."
111
+
107
112
  #define VERSION_DOCSTRING "version(): string -- Returns this module version as string."
108
113
  #define ZSTD_VERSION_DOCSTRING "ZSTD_version(): string -- Returns ZSTD library version as string."
109
114
  #define ZSTD_INT_VERSION_DOCSTRING "ZSTD_version_number(): int -- Returns ZSTD library version as integer.\n Format of the number is: major * 100*100 + minor * 100 + release."
110
115
  #define ZSTD_EXTERNAL_DOCSTRING "ZSTD_external(): int -- Returns 0 or 1 if ZSTD library build as external."
116
+ #define ZSTD_WITH_THREADS_DOCSTRING "ZSTD_with_threads(): int -- Returns 0 or 1 if ZSTD library build with threads support."
117
+ #define ZSTD_WITH_ASM_DOCSTRING "ZSTD_with_asm(): int -- Returns 0 or 1 if ZSTD library build with assembler support."
111
118
  #define ZSTD_THREADS_COUNT_DOCSTRING "ZSTD_threads_count(): int -- Returns ZSTD determined CPU cores count in integer."
112
119
  #define ZSTD_MAX_THREADS_COUNT_DOCSTRING "ZSTD_max_threads_count(): int -- Returns ZSTD library determined maximum working threads count in integer."
113
120