Released the GIL

# New Document
released the GIL to make use of multiple cores when using multithreading.

as per [the docs](https://docs.python.org/3/c-api/init.html#releasing-the-gil-from-extension-code):
>Calling system I/O functions is the most common use case for releasing the GIL, but it can also be useful before calling long-running computations which don’t need access to Python objects, such as compression or **cryptographic functions operating over memory buffers**. For example, the standard zlib and hashlib modules release the GIL when compressing or hashing data.
This commit is contained in:
YoilyL 2019-06-13 19:53:56 +03:00 committed by GitHub
parent 690cda002b
commit 2290f41de9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -51,7 +51,9 @@ static PyObject *ige(PyObject *args, uint8_t encrypt) {
return NULL;
}
Py_BEGIN_ALLOW_THREADS
buf = ige256(data.buf, data.len, key.buf, iv.buf, encrypt);
Py_END_ALLOW_THREADS
PyBuffer_Release(&data);
PyBuffer_Release(&key);
@ -104,7 +106,9 @@ static PyObject *ctr256_encrypt(PyObject *self, PyObject *args) {
return NULL;
}
Py_BEGIN_ALLOW_THREADS
buf = ctr256(data.buf, data.len, key.buf, iv.buf, state.buf);
Py_END_ALLOW_THREADS
PyBuffer_Release(&data);
PyBuffer_Release(&key);
@ -144,7 +148,9 @@ static PyObject *cbc(PyObject *args, uint8_t encrypt) {
return NULL;
}
Py_BEGIN_ALLOW_THREADS
buf = cbc256(data.buf, data.len, key.buf, iv.buf, encrypt);
Py_END_ALLOW_THREADS
PyBuffer_Release(&data);
PyBuffer_Release(&key);