Skip to Content
Fluent Python 第2版 ―Pythonicな思考とコーディング手法
book

Fluent Python 第2版 ―Pythonicな思考とコーディング手法

by Luciano Ramalho, 牧野 聡
November 2025
Intermediate to advanced
984 pages
16h 17m
Japanese
O'Reilly Japan, Inc.
Content preview from Fluent Python 第2版 ―Pythonicな思考とコーディング手法

19章Pythonの並行処理モデル

並行性とは、複数の処理を同時に扱えるようにすることです。

並列性とは、複数の処理を同時に行うことです。

両者は関連していますが、異なる概念です。

前者は構造を表し、後者は実行を表します。

並行性がソリューションを与える課題そのものは、必ずしも並列化可能とは限りません。

—— Rob Pike

Go言語の共同考案者†1

[†1] 講演『Concurrency Is Not Parallelism』(https://fpy.li/19-1)のスライド8より。

Pythonで「複数の処理を同時に扱えるようにする」というのが、この章での主題です。ここには並行プログラミングあるいは並列プログラミングが含まれます。こうした用語にうるさい学界の人々の間でも、並行性と並列性という言葉の定義については合意が得られていません。本書では、上に引用したRob Pikeの非公式な定義に従うことにします。並列プログラミングを扱っているとされる論文や書籍でも、実際には並行性についての言及がほとんどだという例もあります†2

[†2] 筆者が研究や業務をともにしたImre Simon教授(1943年-2009年)は、「2つの言葉が同じものを指すのと、1つの言葉が異なるものを指すのは、科学界での大きな罪である」と述べています。彼はブラジルでの計算機科学の草分けであり、オートマトン理論に先駆的な功績を残したほか、トロピカル幾何学の創始者でもあります。また、フリーソフトウェアとフリーカルチャーを支持していました。

Pikeの定義では、並列性は並行性の1形態です。すべての並列システムは並行性を持っていますが、すべての並行システムが並列性を持っているとは限りません。2000年代初期には我々はシングルコアのマシンを使って、GNU/Linux上で100個のプロセスを並行して扱うことができました。近年の4つのCPUコアを搭載したラップトップでは、通常の利用で200以上のプロセスを問題なく実行できます。一方、200個のタスクを並列で実行したいなら、200個のコアが必要です。つまり実際には、ほとんどの処理は並列ではなく並行で行われます。たとえCPUが4つ以上の処理を同時に実行できないとしても、オペレーティングシステムが数百のプロセスを管理し、それぞれが処理を進められるようにしてくれます。 ...

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.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Fluent Python ―Pythonicな思考とコーディング手法

Fluent Python ―Pythonicな思考とコーディング手法

Luciano Ramalho, 豊沢 聡, 桑井 博之, 梶原 玲子
Architecture Patterns with Python

Architecture Patterns with Python

Harry Percival, Bob Gregory

Publisher Resources

ISBN: 9784814401284Publisher Website