Skip to Content
Intuitive Python
book

Intuitive Python

by David Muller
May 2021
Intermediate to advanced
142 pages
3h 37m
English
Pragmatic Bookshelf
Content preview from Intuitive Python

Choosing ThreadPoolExecutor or ProcessPoolExecutor

Now that you’ve seen how to run code in threads or processes using ThreadPoolExecutor and ProcessPoolExecutor, which should you choose to use at any given time?

Let’s revisit the table we saw earlier in this chapter:

ModuleParadigmObjectShare Memory?Restricted by GIL?
threadingthreadsThreadYesYes
multiprocessingprocessesProcessNoNo

The two primary differences between Thread and Process objects have to do with how memory is shared and how something called the GIL restricts performance.

First, we’ll discuss memory sharing in Thread and Process objects.

Investigating Memory Sharing in Threads and Processes

In general, if you use the Thread object from the threading module, your “threaded” code will ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Pythonic Programming

Pythonic Programming

Dmitry Zinoviev
Python for Geeks

Python for Geeks

Muhammad Asif

Publisher Resources

ISBN: 9781680508635Errata Page