Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Python at the Speed of Light (ok, not really)
Search
Chad Estioco
February 23, 2014
Programming
270
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Python at the Speed of Light (ok, not really)
Talk done for Chikka at PyCon PH 2014.
Chad Estioco
February 23, 2014
More Decks by Chad Estioco
See All by Chad Estioco
Don't Panic
skytreader
0
37
The Use of Useless Things
skytreader
0
490
TDD with Python
skytreader
1
270
Heads of the Hydra
skytreader
0
210
Other Decks in Programming
See All in Programming
地域 SRE コミュニティ最前線 - ホンマでっかSRE勉強会
tk3fftk
0
280
Laravel Boostに学ぶ、AIにPHPを書かせる技術 〜OSSの実装から蒸留するエージェント制御の王道〜
kentaroutakeda
3
540
SREの積み重ねがAI駆動開発のガードレールになった ― 7つの実践/SRE Guardrails The 7
tomoyakitaura
8
5.5k
Generative UI & AI-Assistants for Your Angular Solutions
manfredsteyer
PRO
0
120
これからAgentCoreを触る方へトレンドはGatewayです
har1101
6
510
壊れたパーサから始める関数型設計と構成的なパーサ #fp_matsuri
raiga0310
2
400
Apache Hive: Toward a Cloud Native Lakehouse
okumin
0
160
PHP初心者セッション2026 〜生成AIでは見えない裏側を知る:今だからLAMPを通して仕組みを学ぶ〜
kashioka
0
680
5分で問診!Composer セキュリティ健康診断
codmoninc
0
630
ルールを書いて終わらせないハーネスエンジニアリング
yug1224
4
1.8k
ビデオ通話が繋がる0.2秒で何が起きているのか
supurazako
2
150
Go言語とトイモデルで学ぶTransformerの気持ち / fukuokago23-transformer
monochromegane
0
140
Featured
See All Featured
Designing Experiences People Love
moore
143
24k
Mobile First: as difficult as doing things right
swwweet
225
10k
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.5k
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
600
Faster Mobile Websites
deanohume
310
32k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Balancing Empowerment & Direction
lara
6
1.2k
We Are The Robots
honzajavorek
0
280
Skip the Path - Find Your Career Trail
mkilby
1
170
Navigating Team Friction
lara
192
16k
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
1
2.8k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3k
Transcript
Python in the Speed of Light (ok, not really)
Chad n. chocolate-consuming, code-churning, curious creature currently coding for Chikka’s
Connectiviteam (sic) who? me?
the sad truth: python is s.l.o.w.
the sad truth: python is s.l.o.w. http://benchmarksgame.alioth.debian.org/u64q/benchmark.php? test=all&lang=python3&data=u64q
so how come we can live with it? Source: http://www.python.org/about/quotes/
alas! all is not yet lost! (yay!)
we can optimize stuff (lots of it!)
we can optimize algorithms
[optimize algorithms] Big-“Oh” notation: O(f(n)) naive, what you probably learned
in CS undergrad
we can optimize architecture
[optimize architecture]
we can optimize actual runtime
[optimize runtime] JIT in a nutshell: good? bad?
[optimize runtime] PyPy Stackless
we can optimize hardware
[optimize hardware] do not confuse with CPython!
[optimize hardware] PyCUDA!
[optimize hardware] more in a short while after this mini
public service announcement...
we can also micro-optimize (oh… :[ )
[micro-optimization] if most probable condition: do_stuff() elif next most probable
condition: do_stuff() elif third most probable condition: do_stuff() . . . . . . . . . else: # least probable condition do_stuff() ever heard of this pattern? →
[back to regular programming*] let’s talk a bit about gevent
*pun intended
gevent is… 53.7% Python 35.8% C 10.3% Shell 0.1% Other
See: https://github.com/surfly/gevent
gevent is… 53.7% Python 35.8% C 10.3% Shell 0.1% Other
See: https://github.com/surfly/gevent ← see here, C here?
gevent a closer look installing from github … pip install
cython git+git://github.com/surfly/gevent. git#egg=gevent See: https://github.com/surfly/gevent#installing-from-github
cython: what? when? how?
what cython? Python → machine code
when cython? let C handle the bottleneck
how cython? ...and now, source code
speed of C + syntax of Python? cython everything!
pycuda: numbers/matrices/math anyone?
what about graphics?
cuda comes from nvidia
gpu parallelism + syntax of Python? pycuda everything!
take optimization and benchmarking with grains of salt. lots of
it. experimental set-ups vary greatly from real-world environments.