Is the GIL released while using multithreading with python-opencv? Is the GIL released while using multithreading with python-opencv? numpy numpy

Is the GIL released while using multithreading with python-opencv?


To answer it upfront, it depends on the functions you use.

The most effective way to prove if a function releases the GIL is by checking the corresponding source. Also checking the documentation helps, but often it is simply not documented. And yes, it is cumbersome.

http://scipy-cookbook.readthedocs.io/items/Multithreading.html

[...] numpy code often releases the GIL while it is calculating, so that simple parallelism can speed up the code.

Each project might use their own macro, so if you are familiar with the default macros like Py_BEGIN_ALLOW_THREADS from the C Python API, you might find them being redefined. In Numpy for instance it would be NPY_BEGIN_THREADS_DEF, etc.