Skip to Content
高效能PYTHON程式設計
book

高效能PYTHON程式設計

by Micha Gorelick, Ian Ozsvald
August 2015
Intermediate to advanced
384 pages
7h 42m
Chinese
GoTop Information, Inc.
Content preview from 高效能PYTHON程式設計
理解高效能 Python
|
5
增加更多詢問問題的工作人員將提升我們的速度,直到有 100 個工作人員為止,在此情
況下,整個過程將花費 1 分鐘,單純受限於受訪者回答問題所需耗費的時間,再增加工
作人員將無濟於事,因為額外的工作人員根本無事可做—所有的受訪者都已經有工作人
員在服務了!在此狀況下,減少整體問卷調查時間的唯一方法就是降低個別問卷調查所
需耗費的時間(整體工作的循序部分)。相同地,就 CPU 而言,我們可以增加更多核
心,執行不同的計算區塊,直到我們到達特定核心完成其任務所面臨的瓶頸,換言之,
任何平行計算的瓶頸總是發生在被切割出來的較小循序任務上。
更且,在 Python 裡利用多個核心的主要障礙是 Python 使用
GIL
global interpreter
lock
全域直譯器鎖
)。 GIL 確保 Python 行程(process)一次只能夠執行一個指令,不
管它正在使用幾個核心。這表示,即使有些 Python 程式碼能夠同時存取多個核心,但
在特定時間下,只有一個核心在執行 Python 指令。以先前的問卷調查為例,這表示,
即使我們有 100 個工作人員,同時間只能有 1 個工作人員詢問問題並且聆聽回應,這完
全抹煞了擁有多個工作人員的好處!雖然這看起來好像是很大的障礙—尤其是,目前的
發展趨勢是擁有多個計算單元,而不是擁有更快速的計算單元—然而,這個問題可透過
使用其他的標準程式庫工具(如
multiprocessing
),技術(如
numexpr
Cython),或分
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

Kafka权威指南

Kafka权威指南

Neha Narkhede, Gwen Shapira, Todd Palino
手把手教会你linux

手把手教会你linux

桑德.范.乌格特
流畅的Python

流畅的Python

Luciano Ramalho
精通機器學習

精通機器學習

Aurélien Géron

Publisher Resources

ISBN: 9789863477105