Why is Python slow? Python Nordeste 2013
Upcoming SlideShare
Loading in...5
×
 

Why is Python slow? Python Nordeste 2013

on

  • 2,030 views

 

Statistics

Views

Total Views
2,030
Views on SlideShare
801
Embed Views
1,229

Actions

Likes
0
Downloads
11
Comments
0

42 Embeds 1,229

http://codecereal.blogspot.com.br 376
http://codecereal.blogspot.com 237
http://codecereal.blogspot.no 140
http://codecereal.blogspot.de 71
http://codecereal.blogspot.fr 57
http://codecereal.blogspot.in 41
http://codecereal.blogspot.co.uk 35
http://codecereal.blogspot.ru 27
http://codecereal.blogspot.nl 26
http://codecereal.blogspot.tw 25
http://codecereal.blogspot.com.ar 21
http://codecereal.blogspot.ca 20
http://codecereal.blogspot.com.au 15
http://codecereal.blogspot.it 13
http://codecereal.blogspot.co.at 11
http://codecereal.blogspot.com.es 10
http://codecereal.blogspot.jp 9
http://codecereal.blogspot.kr 9
http://codecereal.blogspot.fi 8
http://codecereal.blogspot.sg 8
http://codecereal.blogspot.pt 8
http://codecereal.blogspot.hu 7
http://codecereal.blogspot.be 7
http://codecereal.blogspot.mx 5
http://codecereal.blogspot.ie 5
http://codecereal.blogspot.co.il 5
http://codecereal.blogspot.ch 4
http://translate.googleusercontent.com 4
http://codecereal.blogspot.ro 4
http://codecereal.blogspot.hk 3
http://codecereal.blogspot.se 2
http://codecereal.blogspot.cz 2
http://codecereal.blogspot.com.tr 2
http://codecereal.blogspot.gr 2
http://feeds.feedburner.com 2
http://codecereal.blogspot.co.nz 2
http://flavors.me 1
http://codecereal.blogspot.ae 1
http://codecereal.blogspot.sk 1
http://yoleoreader.com 1
http://cloud.feedly.com 1
http://www.codecereal.blogspot.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

CC Attribution License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Why is Python slow? Python Nordeste 2013 Why is Python slow? Python Nordeste 2013 Presentation Transcript

  • Why is Pythonslow?Daker Pinheiro
  • Why is CPythonslow?Daker Pinheiro
  • Why is CPython2.x slow?Daker Pinheiro
  • $ whois dakerfpDaker Fernandes PinheiroUFPEINDT RecifeWebKit (Nix)Qt, KDE, ...C++, C, Python, Javascript, Prolog, ...Pythonist since 2009
  • Is Python slow?http://benchmarksgame.alioth.debian.org
  • Is Python slow?http://benchmarksgame.alioth.debian.org
  • Is Python slow?http://benchmarksgame.alioth.debian.org
  • Is Python slow?http://benchmarksgame.alioth.debian.org
  • Is Python slow?http://benchmarksgame.alioth.debian.org
  • InterpretedArchitecture independency
  • PyObject, PyObjectType &PyHeapTypeObject
  • Typeless variables
  • Virtual Stack Machine>>> (z * y) + x + z
  • Virtual Stack Machine
  • Bytecode Inspection>>> import dis>>> dis.dis(lambda x, y, z: (z * y) + x + z)2 0 LOAD_FAST 2 (z)3 LOAD_FAST 1 (y)6 BINARY_MULTIPLY7 LOAD_FAST 0 (x)10 BINARY_ADD11 LOAD_FAST 2 (z)14 BINARY_ADD15 RETURN_VALUE
  • 100 * 100 * 100 * 100vs100 ** 4
  • dict()vs{}
  • Benchmark>>> import timeit>>> timeit.timeit("[i * i for i in xrange(100)]")
  • ConcurrencyGlobal Interpreter LockerAvoid ThreadsTry Event LoopsTry Multiprocess
  • Know your Data StructuresTime Complexity
  • Use C/C++ BindingsnumpyPyQt, PySide...standard library
  • [i * i for i in range(100)]][i * i for i in xrange(100)]][i * i for i in np.arange(100)]]
  • ar = np.arange(100); ar * ar
  • Memory
  • Python 3Similar to Python 2.7 performancePython 3 - Mailing list
  • Cythoncdef average(int a, int b):return (a + b) / 2.0
  • PsycoDead, RIPimport psycopsyco.full()
  • PyPyhttp://speed.pypy.org/
  • Create C/C++ BindingsPython.hSIPBoost.PythonShiboken
  • Optimization Checklist1. Legibillity2. Architecture3. Algorithm4. Memory5. Buffering6. Caching7. IO8. Consider other languages :-(
  • Q & ADaker Fernandes Pinheirohttp://codevereal.blogspot.com