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な思考とコーディング手法

20章並行処理のExecutor

スレッドを批判する人々の多くはシステムプログラマーで、普通のアプリケーションプログラマーなら一生遭遇しないようなユースケースを気にしているのだと思われます。(略)アプリケーションプログラマーにとってのユースケースの99パーセントは、独立のスレッドをいくつか起動して処理を割り振り、結果をキューに集めれば事足りるでしょう。

—— Michele Simionato

Pythonの思索者†1

[†1] Michele Simionatoによる記事『Threads, processes and concurrency in Python: some thoughts』(https://fpy.li/20-1)より。要約として「マルチコアによる(実際には大したことのない)革命への過大評価を取り除き、スレッドやその他の並行処理について(おそらく)有益なコメントを提供する」と書かれています。

この章ではconcurrent.futures.Executor関連のクラス群に着目します。これらはMichele Simionatoの言う通り、独立のスレッドを複数起動して処理結果をキューに集めるというパターンがカプセル化されたしくみです。Executorを使えばこのパターンを苦労なく実現でき、スレッドの代わりにプロセスを利用することも可能です。計算量の多いタスクではプロセスが役立つでしょう。

また、ここではfutureという概念も紹介します。これはJavaScriptでのpromiseと同様に、処理の非同期実行を表すオブジェクトです。ここでの基本的な考え方は、concurrent.futuresだけでなく「21章 非同期プログラミング」で解説するasyncioパッケージの基盤にもなっています。 ...

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, 豊沢 聡, 桑井 博之, 梶原 玲子

Publisher Resources

ISBN: 9784814401284Publisher Website