Develop Parallel Python Programs, Once You Learn Multiprocessing
Imagine developing Python programs that scaled with the number of CPU cores available in your system
Your python code does not have to be slow! (or run on just one cpu)
If you can invest as little as one hour per day, then in one week you will know how to confidently bring parallel programming to your current and future projects.
Convinced? Jump to the book, otherwise read on…
Bo Henningsson
The book ‘Python Multiprocessing Jump-Start’ was easy to understand, even though I knew nothing about multiprocessing in Python.
How Much Faster Could Your Code Run
...if it used all CPU cores?
Has this happened to you...
You develop your Python program to perform some routine task many times, such as in a loop.
You run the script and are frustrated at how long it takes.
Yet, you have 2, 4, 8, or more CPU cores sitting idle.
Using electricity.
Waiting for work.
What a waste!
- What if you could develop Python programs that were parallel from the start?
- What if your parallel Programs used all of the CPU cores in your system the first time?
This is possible right now with a little-used Python module that offers process-based concurrency (and is already installed on your system).
Concurrency is the Path to Faster Code
Python is a joy to use, but getting Python code to run fast is challenging.
Concurrency is a standard approach to running multiple functions simultaneously.
Python concurrency has a bad reputation. So bad, that many developers believe Python does not support true concurrency.
I'm happy to say that these misconceptions are dead wrong.
Python supports real concurrency with first-class native support for threads and processes.
It always has.
- ...on all recent Python versions, like Python v2.6+ and v3.0+.
- ...on all major platforms, like Windows, macOS, and Linux.
- ...with all major hardware, like Intel, AMD, ARM, and Apple Silicon.
And most importantly, Python concurrency is easy and fun to use.
The trick is to use the multiprocessing module...
The "Multiprocessing" Module for Parallelism
....that you've been missing
The multiprocessing module provides easy-to-use process-based concurrency.
This is not some random third-party library that is hard to install, this is the Python standard library (already installed on your system).
This is the module you need to use to make your code run faster.
It is specifically designed for you to develop parallel Python programs and make use of all of the CPU cores available in your system.
It does this by side-stepping the infamous Global Interpreter Lock (GIL).
Unlike processes, Python threads only provide limited parallelism given the presence of the GIL. This is widely known and leads to opinions like:
"Python doesn't support concurrency because of the GIL."
But this is only true for threads, not processed-based concurrency.
The answer is the multiprocessing module.
This module was developed specifically to offer parallelism by side-stepping the GIL completely.
There's just one problem.
Few developers know about it (or how to use it well).
- ...the API documentation is thin at best, providing very little guidance on how to use its features.
- ...the API docs are buried deep within the Python documentation website, making it impossible to find.
- ...the few examples out there on the web are terse and 10 years out of date.
This is madness!
The perfect module for faster parallel Python programs is right there in the standard library, and few Python developers know it exists or can locate it, let alone decipher the API documentation.
Introducing:
"Python Multiprocessing Jump-Start"
"Python Multiprocessing Jump-Start" is my new book that will teach you how to develop parallel programs in Python, from scratch.
This book distills only what you need to know to get started and be effective with multiprocessing, super fast.
It's exactly how I would teach you multiprocessing if we were sitting together, pair programming.
Technical Details:
- 7 lessons taught by example with full working code listings.
- 24 .py code files included that you can use as templates
- 102 pages for on-screen reading open next to your editor.
- 2 formats (PDF and EPUB) for screen, tablet, and kindle reading.
- 2 megabyte .zip download that contains the ebook and all source code.
"Python Multiprocessing Jump-Start" will lead you on the path from a Python developer interested in concurrency to a developer that can confidently develop programs using processes.
- No fluff.
- Just concepts and code.
- With full working examples.
The book is divided into 7 lessons.
The idea is you can read and work through one lesson per day, and become capable in one week.
It is the shortest and most effective path that I know of transforming you into a Parallel Python Engineer.
Choose your package:
BOOK
You get the book:
- Multiprocessing Jump-Start
PDF and EPUB formats
Includes all source code files
BOXED SET
TOP SELLER
You get all 7 books:
- Threading Jump-Start
- Multiprocessing Jump-Start
- Asyncio Jump-Start
- ThreadPool Jump-Start
- Pool Jump-Start
- ThreadPoolExecutor Jump-Start
- ProcessPoolExecutor Jump-Start
(that is a 9.52% discount)
BOOKSHELF
BEST VALUE
You get everything (15+ books):
- Threading Jump-Start
- Multiprocessing Jump-Start
- Asyncio Jump-Start
- ThreadPool Jump-Start
- Pool Jump-Start
- ThreadPoolExecutor Jump-Start
- ProcessPoolExecutor Jump-Start
- Threading Interview Questions
- Multiprocessing Interview Questions
- Asyncio Interview Questions
- Executors Interview Questions
- Concurrent File I/O
- Concurrent NumPy
- Python Benchmarking
- Python Asyncio Mastery
Bonus, you also get:
- Concurrent For Loops Guide
- API Mind Maps (4)
- API Cheat Sheets (7)
That is $210 of Value!
(you get a 10.95% discount)
All prices are in USD.
(also get the book from Amazon, GumRoad, and GooglePlay stores)
See What Customers Are Saying:
P. Cornelio
Very interesting and useful for expanding the detailed knowledge on the development of well-written concurrent and/or parallel programs.
My knowledge of concurrent and parallel programming was already good, and studying your advice gave me a better understanding of Python in detail.
Bo Henningsson
The book ‘Python Multiprocessing Jump-Start’ was easy to understand, even though I knew nothing about multiprocessing in Python. The text was easy to read and the program examples, which were crystal clear, worked without problems to run in my Visual Studio CODE on Windows 10 and Python 3.10.4 (except for ‘fork’, which doesn’t work on Windows) Before I was half way through the book I had written a multitasking Python program that immediately went live, with one user. (which reduced his wait time from 40 minutes to 10 minutes, on each use). 4 times faster! (using 5 cores, on a 6 core processor)
This is a really good book start with if you’re new to the world of multiprocessing
This book covers the basics and empowers you with all the basic concepts. The author clearly explains the skeletal structure behind the multiprocessing functionality. The book also provides excellent references for future readings on detailed concepts.
Lars Klemstein
A really good introduction to Python parallel processing on the right technical level.
Richard Palladino
The SuperFastPython series was exactly what I needed. The information was concise. I was able to understand things much quicker than any other lesson, tutorial, or resource I’d used before. I worked through a lot of the problems I had in the past with my particular use-case and also discovered some things just weren’t possible unless I wanted to recode the dependencies.
I was able to test it and double my speed compared to the BEST results of my past concurrency and async approaches.
Anthony Wilson
Clear. Insightful. Helped me develop from scratch a fully async system used in production
Greatly eases the learning curve for multitasking in Python
ASYNCIO is one Python subsystem for simple multitasking. I wouldn’t classify this library as fully mature and I was struggling greatly to absorb the concepts behind the function calls. I also found it difficult to get the function call syntax right without a bunch of trial-an-error.
I realized that at some point I would need to move some of my tasks to different multi-tasking subsystems. I’d been using the author’s web site for help and discovered the book set. It has provided me with both perspective and practical application of ASYNCIO.
If you don’t have a lot of time to waste learning about this topic and you aren’t into pain, I’d recommend the book set. Well worth the money for me.
Really good!
The whole series of books from Jason is really good. All concepts are well explained, he goes in-depth with clear examples.
Robert Young
Mišel Sabo
I succeed to faster my code using of Process pool 2.3 times. After some additional optimization I have succeed to speed up to 10 times.
Tomex Iskandar
You Get 7 Laser-Focused Lessons
The structure of the book is a course with 7 lessons.
They are:
- Lesson 01: Process-Based Concurrency
- Python Concurrency
- What is Multiprocessing in Python
- Multiprocessing vs Threading
- When to Use Multiprocessing
- Lesson 02: Create and Start Child Processes
- Main Process in Python
- Parent and Child Processes
- Life-Cycle of a Process
- Protect the Entry Point When Using Multiprocessing
- How to Run a Function in a Child Process
- How to Extend the Process Class
- Lesson 03: Configuring and Interacting with Processes
- How to Configure New Processes
- How to Query the Status of a Process
- How to Terminate or Kill a Process
- How to Get the Current, Parent, and Child Processes
- How to Configure the Start Method
- Lesson 04: Synchronize and Coordinate Processes
- How to Protect Critical Sections with a Mutex Lock
- How to Limit Access to a Resource with a Semaphore
- How to Signal Between Processes Using an Event
- How to Coordinate Using a Condition Variable
- How to Coordinate at a Point Using a Barrier
- Lesson 05: Share Data Between Processes
- How to Inherit Global Variables from Parent Processes
- How to Share Python Primitives with ctypes
- How to Send Data to Processes with Pipes
- How to Use Producers and Consumers with Queues
- Lesson 06: Run Tasks with Reusable Workers in Pools
- What Are Process Pools
- How to Use Multiprocessing Pools in Python
- How to Configure the Multiprocessing Pool
- How to Execute Tasks Synchronously and Asynchronously
- How to Use Callback Functions to Process Results
- How to Interact with Asynchronous Tasks
- Lesson 07: Share Centralized Objects with Managers
- What Is a Manager
- How to Use A Manager
- What Objects Do Managers Support
- How to Use a Manager to Share a Data Structure
- How to Use a Manager to Share a Concurrency Primitive
Next, let's look at the structure of each lesson.
Highly-structured lessons on how you can get results
Each lesson has two main parts, they are:
- 1) The lesson body that teaches the concepts and working code examples.
- 2) The lesson review that summarizes what was learned with exercises.
The body of the lesson will introduce a topic with code examples, whereas the lesson overview will review what was learned with exercises and links for further information.
Each lesson has a specific learning outcome and is designed to be completed in about one hour.
Each lesson is also designed to be self-contained so that you can read the lessons out of order if you choose, such as dipping into topics in the future to solve specific programming problems.
We Python developers learn best from real and working code examples. So each lesson has multiple large worked examples with sample output.
Next, let's look at what you will know after finishing the book.
Your Learning Outcomes
Transform from "python developer" into "Python developer that can create scalable and parallel programs using python multiprocessing"
After working through all of the lessons in this book, you will know:
- The difference between thread-based and process-based concurrency and the types of tasks that are well suited to the capabilities of the multiprocessing module.
- How to execute your own ad hoc functions in parallel using the Process class.
- How to identify the main process, about parent and child processes, and the life-cycle of processes in Python.
- How to configure a new child process and access Process instance for running processes, kill them, and query their status such as their exit code and whether they are still running.
- How to coordinate and synchronize Python processes using mutex locks, semaphores, condition variables and the full suite of concurrency primitives.
- How to inherit and use global variables from parent processes when using the fork start method.
- How to share data between processes using shared ctypes, how to send and receive data using pipes and how to create producer and consumer processes using queues.
- How to create and configure multiprocessing pools to execute ad hoc tasks using reusable child worker processes.
- How to process results, handle errors, and query the status of asynchronous tasks executed in multiprocessing pools.
- How to create centralized Python objects that can be accessed and used in a process-safe manner using proxy objects.
You will learn from code examples, not pages and pages of fluff.
Get your copy now:
100% Money-Back Guarantee
(no questions asked)
I want you to actually learn Python multiprocessing so well that you can confidently use it on current and future projects.
I designed my book to read just like I'm sitting beside you, showing you how.
I want you to be happy. I want you to win!
I stand behind all of my materials. I know they get results and I'm proud of them.
Nevertheless, if you decide that my books are not a good fit for you, I'll understand.
I offer a 100% money-back guarantee, no questions asked.
To get a refund, contact me with your purchase name and email address.
Frequently Asked Questions
This section covers some frequently asked questions.
If you have any questions. Contact me directly. Any time about anything. I will do my best to help.
What are your prerequisites?
This book is designed for Python developers who want to discover how to use and get the most out of Python multiprocessing.
Specifically, this book is for:
- Developers that can write simple Python programs.
- Developers that need better performance from current or future Python programs.
- Developers that want to learn concurrent programming in Python.
This book does not require that you are an expert in the Python programming language or concurrency.
Specifically:
- You do not need to be an expert Python developer.
- You do not need to be an expert in concurrency.
What version of python do you need?
All code examples use Python 3.
Python 3.9+ to be exact.
Python 2.7 is not supported because it reached its "end of life" in 2020.
Are there code examples?
Yes.
There are 24 .py code files.
Each lesson has one or more complete, standalone, and fully-working code examples.
The book is provided in a .zip file that includes a src/ directory containing all source code files used in the book.
How long will the book take you to finish?
About 1 hour per lesson.
Work at your own pace.
I recommend 1 lesson per day, over 7 days (1 week).
There's no rush and I recommend that you take your time.
The book is designed to be read linearly from start to finish, guiding you from being a Python developer at the start of the book to being a Python developer that can confidently use Python multiprocessing in your projects by the end of the book.
In order to avoid overload, I recommend completing one lesson per day, such as in the evening or during your lunch break. This will allow you to complete the transformation in about one week.
I recommend you maintain a directory with all of the code you type from the lessons in the book. This will allow you to use the directory as your own private code library, allowing you to copy-paste code into your projects in the future.
I recommend trying to adapt and extend the examples in the lessons. Play with them. Break them. This will help you learn more about how the API works and why we follow specific usage patterns.
What format is the book?
You can read the book on your screen, next to your editor.
You can also read the book on your tablet, away from your workstation.
The ebook is provided in 2 formats:
- PDF (.pdf): perfect for reading on the screen or tablet.
- EPUB (.epub): perfect for reading on a tablet with a Kindle or iBooks app.
Many developers like to read technical books on their tablet or iPad.
How can you get more help?
The lessons in this book were designed to be easy to read and follow.
Nevertheless, sometimes we need a little extra help.
A list of further reading resources is provided at the end of each lesson. These can be helpful if you are interested in learning more about the topic covered, such as fine-grained details of the standard library and API functions used.
The conclusions at the end of the book provide a complete list of websites and books that can help if you want to learn more about Python concurrency and the relevant parts of the Python standard library. It also lists places where you can go online and ask questions about Python concurrency.
Finally, if you ever have questions about the lessons or code in this book, you can contact me any time and I will do my best to help. My contact details are provided at the end of the book.
How many pages is the book?
The PDF is 102 pages.
Can you print the book?
Yes.
Although, I think it's better working through it on the screen.
- You can search, skip, and jump around really fast.
- You can copy-and-paste code examples.
- You can compare code output directly.
Is there digital rights management?
No.
The ebooks have no DRM.
Do you get free updates?
Yes.
Each time I release an updated version, I will send you an email with a link so that you can download the latest version for free.
You can also email me any time and I will send you the latest version.
Can you buy the book elsewhere?
Yes!
You can get a kindle or paperback version from Amazon.
Many developers prefer to buy from the kindle store on amazon directly.
In fact, the book was the #1 new release in its category shortly after its release.
Can you get a paperback version of the book?
Yes!
You can get a paperback version from Amazon.
Below is a photo of the paperback and kindle versions of the book on my bench.
Can you read a sample of the book?
Yes.
You can read a book sample via google books "preview" or via the amazon "look inside" feature:
Generally, if you like my writing style on SuperFastPython, then you will like the books.
Can you download the source code now?
The source code (.py) files are included in the .zip with the book.
Nevertheless, you can also download all of the code from the dedicated GitHub Project:
Does multiprocessing work on your operating system?
Yes.
Python concurrency is built into the Python programming language and works equally well on:
- Windows
- macOS
- Linux
Does multiprocessing work on your hardware?
Yes.
Python concurrency is agnostic to the underlying CPU hardware.
If you are running Python on a modern computer, then you will have support for concurrency, e.g. Intel, AMD, ARM, and Apple Silicon CPUs are supported.
How does the "Jump-Start Book" compare to the "Complete Guides"?
The SuperFastPython Jump-Start books are laser-focused on making you productive with a Python concurrency module or class as fast as possible.
This means that many broader topics are not covered because they are not on the critical path.
The guides on SuperFastPython.com are broader in scope and compare the class or module to related modules, describing best practices, common errors, common usage questions, and common objects.
This material may be interesting but is a distraction when you are focused on getting productive as fast as possible.
Another important difference is that the jump-start books are provided in book form, whereas the guides are very long web pages.
This makes the books easy to read on a kindle, tablet, or paperback, as well as the screen, whereas the guides must be read in the browser.
About the Author
Hi, I'm Jason Brownlee, Ph.D.
I'm a Python developer, husband, and father to two boys.
I want to share something with you.
I am obsessed with Python concurrency, but I wasn't always this way.
My background is in Artificial Intelligence and I have a few fancy degrees and past job titles to prove it.
You can see my LinkedIn profile here:
- Jason Brownlee LinkedIn Profile
(follow me if you like)
So what?
Well, AI and machine learning has been hot for the last decade. I have spent that time as a Python machine learning developer:
- Working on a range of predictive modeling projects.
- Writing more than 1,000+ tutorials.
- Authoring over 20+ books.
There's one thing about machine learning in Python, your code must be fast.
Really fast.
Modeling code is already generally fast, built on top of C and Fortran code libraries.
But you know how it is on real projects…
You always have to glue bits together, wrap the fast code and run it many times, and so on.
Making code run fast requires Python concurrency and I have spent most of the last decade using all the different types of Python concurrency available.
Including threading, multiprocessing, asyncio, and the suite of popular libraries.
I know my way around Python concurrency and I am deeply frustrated at the bad wrap it has.
This is why I started SuperFastPython.com where you can find hundreds of free tutorials on Python concurrency.
And this is why I wrote this book.
Praise for Super Fast Python
Python developers write to me all the time and let me know how helpful my tutorials and books have been.
Below are some select examples posted to LinkedIn.
What Are You Waiting For?
Stop reading outdated StackOverflow answers.
Learn Python concurrency correctly, step-by-step.
Start today.
Buy now and get your copy in seconds!