Skip to Content
ハイパフォーマンスPython 第2版
book

ハイパフォーマンスPython 第2版

by Micha Gorelick, Ian Ozsvald, 中山 光樹
April 2023
Intermediate to advanced
452 pages
7h 21m
Japanese
O'Reilly Japan, Inc.
Content preview from ハイパフォーマンスPython 第2版

6章行列とベクトルの計算

6章を読めば以下の問いに答えられるようになる
  • ベクトルの計算でボトルネックとなる箇所はどこか?
  • CPUの計算効率を調べるツールには何があるか?
  • なぜNumPyはPythonだけで書くより数値計算が得意なのか?
  • キャッシュミスページフォールトとは何か?
  • コード上のメモリ確保を追跡する方法は?

 どのような問題であろうと、コンピュータで解決しようとすれば、どこかでベクトルの計算が絡むものです。ベクトルの計算は、コンピュータの動作やハードウェアのレベルまで考慮してプログラムの実行時間を短縮するのに欠かせません。コンピュータが知っていることは数値演算だけです。そのため、一度に複数の計算をする方法がわかれば、プログラムを高速化するのに役立ちます。

 本章では、拡散方程式を解くという比較的単純な数学的問題をテーマに、CPUレベルでの動作を理解することで、ベクトル計算の複雑さを明らかにします。コードの変化がCPUに与える影響を理解し、効率よく精査する方法を知ることで、他の問題も理解できるようになります。

 まず、扱う問題を紹介し、Pythonだけで解いてみます。発生するメモリの問題をPythonだけで解決したら、NumPyを導入し、コードが高速になる仕組みと理由を示します。次に、アルゴリズムを変更して、NumPyで問題を解決できるようにします。ここではNumPyの持つ汎用性の一部を除去することで、コードをさらに高速化できることを示します。そのあと、一連の作業を支援する外部モジュールを導入し、プロファイリングせずに最適化することの危険性を述べます。

 最後に、Pandasを紹介します。Pandasは、NumPyをベースに、同種のデータの列を取り、違う型のテーブルに格納します。Pandasは純粋な ...

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

ハイパフォーマンスPython

ハイパフォーマンスPython

Micha Gorelick, Ian Ozsvald, 相川 愛三
Rクックブック 第2版

Rクックブック 第2版

J.D. Long, Paul Teetor, 大橋 真也, 木下 哲也
Node.jsデザインパターン 第2版

Node.jsデザインパターン 第2版

Mario Casciaro, Luciano Mammino, 武舎 広幸, 阿部 和也
PythonによるWebスクレイピング 第2版

PythonによるWebスクレイピング 第2版

Ryan Mitchell, 黒川 利明, 嶋田 健志

Publisher Resources

ISBN: 9784873119908Other