Skip to content

Commit 0d1ab38

Browse files
authored
Merge pull request #38 from sudeep9/master
Removed GIL lock while compress and decompress
2 parents 6eff36f + 038239a commit 0d1ab38

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

snappymodule.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ snappy__compress(PyObject *self, PyObject *args)
111111
result = PyBytes_FromStringAndSize(NULL, compressed_size);
112112
if (result) {
113113
actual_size = compressed_size;
114+
Py_BEGIN_ALLOW_THREADS
114115
status = snappy_compress(input, input_size, PyBytes_AS_STRING(result), &actual_size);
116+
Py_END_ALLOW_THREADS
115117
if (status == SNAPPY_OK) {
116118
return maybe_resize(result, compressed_size, actual_size);
117119
}
@@ -153,7 +155,9 @@ snappy__uncompress(PyObject *self, PyObject *args)
153155
result = PyBytes_FromStringAndSize(NULL, uncomp_size);
154156
if (result) {
155157
actual_size = uncomp_size;
158+
Py_BEGIN_ALLOW_THREADS
156159
status = snappy_uncompress(compressed, comp_size, PyBytes_AS_STRING(result), &actual_size);
160+
Py_END_ALLOW_THREADS
157161
if (SNAPPY_OK == status) {
158162
return maybe_resize(result, uncomp_size, actual_size);
159163
}

0 commit comments

Comments
 (0)