What feature I did not
know Python has
Joseph Marvin R. Imperial
De La Salle University
I just discovered that
Python
supports multi-core processing without using external
framework or software, just a built-in internal package.
The Multiprocessing Package
• supports spawning processes using an API similar to the
threading module.
• offers both local and remote concurrency, effectively side-
stepping the Global Interpreter Lock by using subprocesses
instead of threads.
• allows the programmer to fully leverage multiple processors
on a given machine.
• runs on both Unix and Windows.
The Global Interpreter Pain
Sample Code
from multiprocessing import Pool
def f(x):
return x*x
if __name__ == '__main__':
p = Pool(5)
print([Link](f, [1, 2, 3]))
Utilizing the package
References
[1] Python Documentation - multiprocessing - Process-based
"threading" interface. (n.d.). Retrieved from
[Link]