I heard about the Python GIL issue, which said that only one Python thread can execute Python bytecode at a time in a multi-core machine. So a multithreaded Python program is not a good idea.
I am wondering if I can write a C extension that creates pthread, which potentially loads the performance of my program. I mean, I am creating a thread in my C extension and hope that it will work in parallel with the main Python thread.
My guess is that the main Python thread will do more with IO; and pthread in my C extension will spend most of the time computing. The main Python thread communicates with the thread in the C extension using a queue (for example, a consumer-producer model).
Is there any difference between multi-threaded with Python extension and C?
source
share