Python Parallel Programming Cookbook cover

Python Parallel Programming Cookbook

No rating yet
Word count
360 words
Chapters
6
ISBN
9787121337536

Tags

Summary

Python Parallel Programming Cookbook is the Chinese translation of the book by the Italian author Giancarlo Zaccone. The original was published by Packt Publishing in 2015; the Chinese edition, translated by Zhang Long and Song Bingjin, was released by Publishing House of Electronics Industry in April 2018. The book has six chapters in a "cookbook" format: each topic revolves around a complete, runnable Python program, explaining the approach and then showing the output, so readers can start immediately and adapt the code for their own projects. Chapter 1 begins with the memory architecture and programming models of parallel computing, explains how to design parallel programs and evaluate their performance, and places Python in the parallel world along with basic concepts of processes and threads. Chapter 2 covers thread-based parallelism, using the threading module to demonstrate thread definition, Lock/RLock, semaphores, condition variables, events, the with statement, and queue-based communication, and discusses performance evaluation of multithreaded applications. Chapter 3 turns to process-based parallelism, covering process creation, naming, running in the background, termination, process pools, and inter-process synchronization, and uses mpi4py to introduce point-to-point communication, deadlock avoidance, and collective communication such as broadcast, scatter, gather, and Alltoall. Chapter 4 covers asynchronous programming, introducing concurrent.futures and asyncio's event loop, coroutines, tasks, and Futures. Chapter 5 discusses distributed Python, involving Celery, SCOOP, Pyro4, PyCSP, MapReduce on Disco, and RPyC. Chapter 6 covers GPU programming, using PyCUDA, NumbaPro, and PyOpenCL to demonstrate numerical computation on GPUs. Note that the original dates from the early Python 3 era; libraries such as NumbaPro are no longer maintained, and some APIs differ from current versions, so readers should focus on understanding principles and approaches.

Editor's review

很多并行编程书先堆砌概念,读者读完仍不知道从哪下手。这本书选择了相反的路子:每讲一个知识点,就给一段能直接跑起来的 Python 代码,再附上运行输出,读者可以边敲边看效果。 结构上是完整的“台阶”:先讲内存架构与性能评估,让人明白为什么要并行、怎样判断并行有没有收益;再从线程讲到进程,把锁、信号量、条件变量、事件、队列这些容易出错的同步原语逐个拆开演示;接着是 mpi4py 的点对点与聚合通信,分布式部分覆盖 Celery、SCOOP、Pyro4、Disco、RPyC,最后落到 PyCUDA、PyOpenCL 的 GPU 编程。一本书把从单机多线程到多机分布式、再到异构计算的常见路径走了一遍,对建立整体地图很有价值。 中文版由张龙、宋秉金翻译,术语基本沿用了社区通行译法,代码与正文分离清楚,查阅方便。需要说明的是,原书出版较早,NumbaPro 等库已不再维护,部分示例需要做版本适配;但书中对同步原语、通信模式与性能评估的讲解并不过时,作为一本“随时翻、照着做”的手册仍然实用。

Who it's for

A good fit for

  • 已掌握 Python 基础语法、想系统学习并发与并行编程的开发者
  • 需要在项目中提升数据处理或科学计算性能的工程师
  • 准备学习 mpi4py、Celery、PyCUDA 等并行与分布式工具的技术人员
  • 计算机相关专业学生,用于配合课程做并行编程实验

Not a good fit for

  • 尚无 Python 编程经验的零基础读者,示例难以独立运行
  • 只想要理论推导与算法证明、不关心代码实现的读者
  • 期望覆盖最新 Python 版本与主流替代库(如 Numba 新 API)的读者

Reading tips

  1. 建议先读第 1 章的性能评估部分,学会用 Amdahl 定律等方法判断并行是否值得做。
  2. 按“线程—进程—异步—分布式—GPU”的顺序推进,动手运行并改造每章示例。
  3. 运行示例时注意版本差异,NumbaPro 等已停更的库可用 Numba 等替代,理解思路优先于照抄代码。

About the publisher

Publishing House of Electronics Industry China · Founded in 1982

The Publishing House of Electronics Industry is a comprehensive publisher distinguished by its focus on electronic information and related fields. Judging from the more than 3,000 titles in its catalogue, its publishing covers programming and design, artificial intelligence, computer science, finance and economics, photography, and social sciences, attending both to cutting-edge technology and to general readers. Representative titles include Factor Investing: Methods and Practice, x86 Assembly Language: From Real Mode to Protected Mode, The RISC-V Reader, Artificial Intelligence: Speech Recognition, Understanding and Practice, Phased Array Radar Technology, Radar Target Characteristics, and 100 Go Mistakes and How to Avoid Them, most of which centre on technical methods and engineering practice. Its authors include Shi Chuan, Li Zhong, Wang Xiaobo, David Patterson, Andrew Waterman, and Yu Zihao, among others from China and abroad. Owing to limited public information, no further publishing features are elaborated here.

Contents

  1. Chapter 1 Getting Started with Parallel Computing and Python: Memory Architecture for Parallel Computing; Memory Organization; Parallel Programming Models; How to Design Parallel Programs; How to Evaluate the Performance of Parallel Programs; Introduction to Python; Python in the Parallel World; Introduction to Processes and Threads
  2. Chapter 2 Thread-Based Parallelism: Using Python's threading Module; How to Define a Thread; How to Determine the Current Thread; How to Use a Thread in a Subclass; Synchronizing Threads with Lock and RLock; Synchronizing Threads with Semaphores; Synchronizing Threads with Conditions; Synchronizing Threads with Events; Using the with Statement; Communicating Between Threads with Queues; Evaluating the Performance of Multithreaded Applications
  3. Chapter 3 Process-Based Parallelism: How to Spawn a Process; How to Name a Process; How to Run a Process in the Background; How to Kill a Process; How to Use a Process in a Subclass; How to Exchange Objects Between Processes; How to Synchronize Processes; How to Manage State Between Processes; How to Use a Process Pool; Using the mpi4py Module; Point-to-Point Communication; Avoiding Deadlocks; Collective Communication with Broadcast/Scatter/Gather/Alltoall; Reduction Operations; How to Optimize Communication
  4. Chapter 4 Asynchronous Programming: Using Python's concurrent.futures Module; Event Loop Management with Asyncio; Handling Coroutines with Asyncio; Managing Tasks with Asyncio; Using Asyncio with Futures
  5. Chapter 5 Distributed Python: Distributing Tasks with Celery; How to Create Tasks with Celery; Scientific Computing with SCOOP; Handling Map Functions with SCOOP; Remote Method Invocation with Pyro4; Linking Objects with Pyro4; Developing a Client-Server Application with Pyro4; Communicating Sequential Processes with PyCSP; MapReduce with Disco; Remote Procedure Calls with RPyC
  6. Chapter 6 GPU Programming with Python: Using the PyCUDA Module; How to Build a PyCUDA Application; Understanding the PyCUDA Memory Model Through Matrix Operations; Invoking Kernels with GPUArray; Evaluating Element-wise Expressions with PyCUDA; MapReduce Operations with PyCUDA; GPU Programming with NumbaPro; Using GPU-Accelerated Libraries Through NumbaPro; Using the PyOpenCL Module; How to Build a PyOpenCL Application; Element-wise Operations with PyOpenCL

FAQ

这本书有中文版吗?
有。中文版名为《Python并行编程手册》,由张龙、宋秉金翻译,电子工业出版社 2018 年 4 月出版,ISBN 为 9787121337536,原著为 Packt 出版的 Python Parallel Programming Cookbook。
这本书的作者是谁?
作者是意大利的詹卡洛·扎克尼(Giancarlo Zaccone),拥有物理学硕士学位与科学计算方向的研究生学位,长期从事并行科学计算与软件系统开发工作。
零基础可以读这本书吗?
不太合适。书中示例默认读者熟悉 Python 语法与基本开发环境,并行部分又涉及线程同步、消息传递等概念,建议先具备 Python 项目开发经验再读。
书中的代码现在还能直接运行吗?
大部分可以,但需注意差异:原书基于 Python 3 早期版本,NumbaPro 已停止维护,mpi4py、PyCUDA 等接口也有变化。建议对照所用版本官方文档调整示例,重点理解思路。
这本书一共多少章?
全书共 6 章,依次为并行计算与 Python 起步、基于线程的并行、基于进程的并行、异步编程、分布式 Python、使用 Python 进行 GPU 编程。

Comments

Find this book

This site is an index: you start “Search all sources” in your browser, and the entries it lists all point to third-party sites; please judge their availability yourself.

Top rated in the same category