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程式設計
透過效能分析找出瓶頸
|
23
-0.82+0j
(虛線帶有菱形標記)而言,可以看到,在第 9 次迭代之後,絕對值已經超
+2
,所以我們停止迭代。
計算完整的 Julia Set
在這一節裡,我們分解產生 Julia set 的程式碼。貫穿本章,我們會以幾種方式分析它。
如範例 2-1 所示,在模組一開頭,匯入(import)我們的第一個效能分析方法會用到的
time
模組,並且定義一些座標常數。
範例
2-1 
為座標空間定義全域常數
"""Julia set generator without optional PIL-based image drawing"""
import time
# 要調查的複數空間區域
x1, x2, y1, y2 = -1.8, 1.8, -1.8, 1.8
c_real, c_imag = -0.62772, -.42193
為了產生圖形,我們建立兩個輸入資料的串列。第 1 個是
zs
(複數的 z 座標),第 2
cs
(複數的初始條件)。兩個串列都不會改變,而且我們可以將
cs
最佳化成單一的常
c
值。然而,建造兩個輸入串列的基本理由是:在本章稍後分析 RAM 的使用量時,
會有看起來比較適用的資料可以分析。
為了建立
zs
cs
串列,我們必須知道每個
z
值的座標。在範例 2-2 中,我們使用
xcoord
ycoord
以及指定的
x_step
y_step
建立這些座標。這裡有點囉嗦,但在將程
式碼移植到其他工具(例如,
numpy
)及其他 Python 環境時會有用,因為它有助於讓一 ...
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