| Start |
|---|
Using the multiprocessing module to parallelise tasks As the execution of each call to Python 2.2+ |
| Using a C-extension to parallelize tasks The idea here is to move the computationally intensive jobs to C (using special macros), independent of Python, and have the C code release the GIL while it's working. |
| Using Parent and Children scripts to execute code in parallel child.py parent.py This is useful for parallel, independent HTTP request/response tasks or Database select/inserts. Command line arguments can be given to the child.py script as well. Synchronization between scripts can be achieved by all scripts regularly checking a separate server (like a Redis instance). |
| Using PyPar module to parallelize PyPar is a library that uses the message passing interface (MPI) to provide parallelism in Python. A simple example in PyPar (as seen at https://github.com/daleroberts/pypar) (opens new window)) looks like this: RemarksDue to the GIL (Global interpreter lock) only one instance of the python interpreter executes in a single process. So in general, using multi-threading only improves IO bound computations, not CPU-bound ones. The GIL applies to CPython, the most popular implementation of Python, as well as PyPy. Other implementations such as Jython and IronPython have no GIL (opens new window). |
Read Article
https://develop.horje.com/learn/1434/reference