The Python Gil blocks python code from running on multiple CPUs at the same time. In order to achieve concurrency, we can use module development that is not restricted to Gil,
For compute-intensive programs, concurrency can be achieved using the multiprocessing module, and for I/O intensive programs, you can use multiprocessing You can also use threading or Concurrent.futures modules to implement concurrency.
Too close to the underlying concurrency API is prone to error, in order to avoid this, you can use the Python Quue and multiprocessing modules without explicit lock (explicit lock), which provides a highly encapsulated queue structure, On the other hand, concurrent.futures can also be used.
Enhanced performance:
Use the pypy JIT compiler to speed up python;
Using modules written in C, such as arrays and numpy, to process an array;
Use Cprofile to analyze performance bottlenecks;
For modules that have been implemented in the C/C + +, or any module that conforms to the language calling convention (c calling convention), they can be found from pypi.python.org;
The above modules can be used cTYPES module or third party Cython package to call C program Library when PyPI cannot find it;
Python Advanced Programming