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
0
230
Python at the Speed of Light (ok, not really)
Talk done for Chikka at PyCon PH 2014.
Chad Estioco
February 23, 2014
Tweet
Share
More Decks by Chad Estioco
See All by Chad Estioco
Don't Panic
skytreader
0
32
The Use of Useless Things
skytreader
0
450
TDD with Python
skytreader
1
230
Heads of the Hydra
skytreader
0
180
Other Decks in Programming
See All in Programming
ベクトル検索のフィルタを用いた機械学習モデルとの統合 / python-meetup-fukuoka-06-vector-attr
monochromegane
2
390
RAGでハマりがちな"Excelの罠"を、データの構造化で突破する
harumiweb
9
2.8k
ふつうの Rubyist、ちいさなデバイス、大きな一年
bash0c7
0
830
New in Go 1.26 Implementing go fix in product development
sunecosuri
0
420
米国のサイバーセキュリティタイムラインと見る Goの暗号パッケージの進化
tomtwinkle
2
550
Codexに役割を持たせる 他のAIエージェントと組み合わせる実務Tips
o8n
4
1.3k
AI Assistants for Your Angular Solutions
manfredsteyer
PRO
0
130
コードレビューをしない選択 #でぃーぷらすトウキョウ
kajitack
3
890
Railsの気持ちを考えながらコントローラとビューを整頓する/tidying-rails-controllers-and-views-as-rails-think
moro
5
390
エラーログのマスキングの仕組みづくりに役立ったASTの話
kumoichi
0
180
Go 1.26でのsliceのメモリアロケーション最適化 / Go 1.26 リリースパーティ #go126party
mazrean
1
380
Cyrius ーLinux非依存にコンテナをネイティブ実行する専用OSー
n4mlz
0
130
Featured
See All Featured
Designing for Timeless Needs
cassininazir
0
160
Fashionably flexible responsive web design (full day workshop)
malarkey
408
66k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.3k
Leo the Paperboy
mayatellez
4
1.5k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
1
1.4k
Mind Mapping
helmedeiros
PRO
1
120
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
190
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
440
RailsConf 2023
tenderlove
30
1.4k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
100
Building the Perfect Custom Keyboard
takai
2
710
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.