0% found this document useful (0 votes)
24 views7 pages

Discover Python's Multiprocessing Feature

The document discusses Python's built-in multiprocessing package which allows programs to leverage multiple processors without external frameworks. It supports spawning processes similarly to threading, offers local and remote concurrency by using subprocesses instead of threads, and allows fully utilizing multiple processors on a machine. A sample code demonstrates creating a pool of 5 processes to calculate squares in parallel.

Uploaded by

Joseph Imperial
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views7 pages

Discover Python's Multiprocessing Feature

The document discusses Python's built-in multiprocessing package which allows programs to leverage multiple processors without external frameworks. It supports spawning processes similarly to threading, offers local and remote concurrency by using subprocesses instead of threads, and allows fully utilizing multiple processors on a machine. A sample code demonstrates creating a pool of 5 processes to calculate squares in parallel.

Uploaded by

Joseph Imperial
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

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]

You might also like