Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Parallel Programming with Python

You're reading from  Parallel Programming with Python

Product type Book
Published in Jun 2014
Publisher
ISBN-13 9781783288397
Pages 124 pages
Edition 1st Edition
Languages

Table of Contents (16) Chapters

Parallel Programming with Python
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
1. Contextualizing Parallel, Concurrent, and Distributed Programming 2. Designing Parallel Algorithms 3. Identifying a Parallelizable Problem 4. Using the threading and concurrent.futures Modules 5. Using Multiprocessing and ProcessPoolExecutor 6. Utilizing Parallel Python 7. Distributing Tasks with Celery 8. Doing Things Asynchronously Index

Using multiprocessing to compute Fibonacci series terms with multiple inputs


Let's implement the case study of processing a Fibonacci series for multiple inputs using the processes approach instead of threads.

The multiprocessing_fibonacci.py code makes use of the multiprocessing module, and in order to run, it imports some essential modules as we can observe in the following code:

import sys, time, random, re, requests
import concurrent.futures
from multiprocessing import, cpu_count, current_process, Manager

Some imports have been mentioned in the previous chapters; nevertheless, some of the following imports do deserve special attention:

  • cpu_count: This is a function that permits obtaining the quantity of CPUs in a machine

  • current_process: This is a function that allows obtaining information on the current process, for example, its name

  • Manager: This is a type of object that allows sharing Python objects among different processes by means of proxies (for more information, see http://docs...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}