Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
gh-132983: Introduce_zstd bindings module#133027
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes from1 commit
9814e3bfda87c8887e564cdba6566b67e9ba99a5d202cd17a54eca74f6059562eadc658eac35426775beeae460f2ab5e4ad5bf1c19e92b9f47f815a6a4f7b8d7b3805c225ea66e8c61ce52ad062a1ad8b94473b9e2b2515cd2f08579e174fce6f79ce15dd85685a3d11b9f78640c653c428677d0962bbb85efc18cadf6e4e45c22ab9415be6760545c082d8ae825285f02ff5a0d69c8c58b0008c786c3ca9d57fccc9ab2a1f65d19552da2dc0648d8d149b2ca5ea3790d88d6d4a0a33e30b393490b91728fdc7f710e2e80d90b29dFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -94,7 +94,8 @@ _PyZstd_set_c_parameters(ZstdCompressor *self, PyObject *level_or_options, | ||
| if (key_v == ZSTD_c_compressionLevel) { | ||
| /* Save for generating ZSTD_CDICT */ | ||
| self->compression_level = value_v; | ||
| } | ||
| else if (key_v == ZSTD_c_nbWorkers) { | ||
| /* From zstd library doc: | ||
| 1. When nbWorkers >= 1, triggers asynchronous mode when | ||
| used with ZSTD_compressStream2(). | ||
| @@ -177,7 +178,8 @@ _get_CDict(ZstdDict *self, int compressionLevel) | ||
| goto error; | ||
| } | ||
| Py_DECREF(capsule); | ||
| } | ||
| else { | ||
| /* ZSTD_CDict instance already exists */ | ||
| cdict = PyCapsule_GetPointer(capsule, NULL); | ||
| } | ||
| @@ -206,7 +208,8 @@ _PyZstd_load_c_dict(ZstdCompressor *self, PyObject *dict) { | ||
| ret = PyObject_IsInstance(dict, (PyObject*)mod_state->ZstdDict_type); | ||
| if (ret < 0) { | ||
| return -1; | ||
| } | ||
| else if (ret > 0) { | ||
| /* When compressing, use undigested dictionary by default. */ | ||
| zd = (ZstdDict*)dict; | ||
| type = DICT_TYPE_UNDIGESTED; | ||
| @@ -220,7 +223,8 @@ _PyZstd_load_c_dict(ZstdCompressor *self, PyObject *dict) { | ||
| (PyObject*)mod_state->ZstdDict_type); | ||
| if (ret < 0) { | ||
| return -1; | ||
| } | ||
| else if (ret > 0) { | ||
| /* type == -1 may indicate an error. */ | ||
| type = PyLong_AsInt(PyTuple_GET_ITEM(dict, 1)); | ||
| if (type == DICT_TYPE_DIGESTED || | ||
| @@ -251,7 +255,8 @@ _PyZstd_load_c_dict(ZstdCompressor *self, PyObject *dict) { | ||
| Py_BEGIN_CRITICAL_SECTION(self); | ||
| zstd_ret = ZSTD_CCtx_refCDict(self->cctx, c_dict); | ||
| Py_END_CRITICAL_SECTION(); | ||
| } | ||
| else if (type == DICT_TYPE_UNDIGESTED) { | ||
| /* Load a dictionary. | ||
| It doesn't override compression context's parameters. */ | ||
| Py_BEGIN_CRITICAL_SECTION2(self, zd); | ||
| @@ -260,15 +265,17 @@ _PyZstd_load_c_dict(ZstdCompressor *self, PyObject *dict) { | ||
| PyBytes_AS_STRING(zd->dict_content), | ||
| Py_SIZE(zd->dict_content)); | ||
emmatyping marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| Py_END_CRITICAL_SECTION2(); | ||
| } | ||
| else if (type == DICT_TYPE_PREFIX) { | ||
| /* Load a prefix */ | ||
| Py_BEGIN_CRITICAL_SECTION2(self, zd); | ||
| zstd_ret = ZSTD_CCtx_refPrefix( | ||
| self->cctx, | ||
| PyBytes_AS_STRING(zd->dict_content), | ||
| Py_SIZE(zd->dict_content)); | ||
| Py_END_CRITICAL_SECTION2(); | ||
| } | ||
| else { | ||
| /* Impossible code path */ | ||
| PyErr_SetString(PyExc_SystemError, | ||
emmatyping marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| "load_c_dict() impossible code path"); | ||
| @@ -412,7 +419,8 @@ compress_impl(ZstdCompressor *self, Py_buffer *data, | ||
| in.src = data->buf; | ||
| in.size = data->len; | ||
| in.pos = 0; | ||
| } | ||
| else { | ||
| in.src = ∈ | ||
| in.size = 0; | ||
| in.pos = 0; | ||
| @@ -511,7 +519,8 @@ compress_mt_continue_impl(ZstdCompressor *self, Py_buffer *data) | ||
| if (_OutputBuffer_Grow(&buffer, &out) < 0) { | ||
| goto error; | ||
| } | ||
| } | ||
| else if (in.pos == in.size) { | ||
| /* Finished */ | ||
| assert(mt_continue_should_break(&in, &out)); | ||
| break; | ||
| @@ -569,13 +578,15 @@ _zstd_ZstdCompressor_compress_impl(ZstdCompressor *self, Py_buffer *data, | ||
| /* Compress */ | ||
| if (self->use_multithread && mode == ZSTD_e_continue) { | ||
| ret = compress_mt_continue_impl(self, data); | ||
| } | ||
| else { | ||
| ret = compress_impl(self, data, mode); | ||
| } | ||
| if (ret) { | ||
| self->last_mode = mode; | ||
| } | ||
| else { | ||
| self->last_mode = ZSTD_e_end; | ||
| /* Resetting cctx's session never fail */ | ||
| @@ -621,7 +632,8 @@ _zstd_ZstdCompressor_flush_impl(ZstdCompressor *self, int mode) | ||
| if (ret) { | ||
| self->last_mode = mode; | ||
| } | ||
| else { | ||
| self->last_mode = ZSTD_e_end; | ||
| /* Resetting cctx's session never fail */ | ||
Uh oh!
There was an error while loading.Please reload this page.