Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

PyParis2017 / Performant python, by Burkhard Kloss

128 views

Published on

PyParis 2017
http://pyparis.org

Published in: Technology
  • Be the first to comment

  • Be the first to like this

PyParis2017 / Performant python, by Burkhard Kloss

  1. 1. Performant Python how to write good, fast, python code @georgebernhard bk@xk7.com
  2. 2. how to write good, fast, python code
  3. 3. how to write good, fast, python code how to write good, fast, python code
  4. 4. how to write good, fast, python code how to write good, fast, python code how to write good, fast, python code
  5. 5. import this Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts.
  6. 6. how to write good, fast, python code how to write good, fast, python code how to write good, fast, python code
  7. 7. https://twitter.com/jakevdp/status/850373744644182017
  8. 8. Programmers are expensive Computers are cheap
  9. 9. how to write good, fast, python code how to write good, fast, python code how to write good, fast, python code
  10. 10. how to write good, fast, python code
  11. 11. how to write good, fast, python code
  12. 12. how to write good, fast, python code
  13. 13. Programmers waste enormous amounts of time thinking about, or worrying about, the speed of noncritical parts of their programs, and these attempts at efficiency actually have a strong negative impact when debugging and maintenance are considered.
  14. 14. Programmers waste enormous amounts of time thinking about, or worrying about, the speed of noncritical parts of their programs, and these attempts at efficiency actually have a strong negative impact when debugging and maintenance are considered. We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil.
  15. 15. Programmers waste enormous amounts of time thinking about, or worrying about, the speed of noncritical parts of their programs, and these attempts at efficiency actually have a strong negative impact when debugging and maintenance are considered. We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%. Donald Knuth
  16. 16. how to write good, fast, python code
  17. 17. Profiling
  18. 18. Batteries included! python -m cProfile anagram0.py > profile_anagram0.txt
  19. 19. how to write good, fast, python code
  20. 20. how to write good, fast, python code
  21. 21. Programmers waste enormous amounts of time thinking about, or worrying about, the speed of noncritical parts of their programs, and these attempts at efficiency actually have a strong negative impact when debugging and maintenance are considered. We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%. Donald Knuth
  22. 22. how to write good, fast, python code
  23. 23. Programmers waste enormous amounts of time thinking about, or worrying about, the speed of noncritical parts of their programs, and these attempts at efficiency actually have a strong negative impact when debugging and maintenance are considered. We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%. Donald Knuth
  24. 24. “Premature optimization is the root of all evil, so to start this project I'd better come up with a system that can determine whether a possible optimization is premature or not."
  25. 25. Fin.
  26. 26. Micro optimisations
  27. 27. http://www.freeimageslive.co.uk/f
  28. 28. If you want to see my slides on micro optimisations, you can see them below.
  29. 29. Anagrams
  30. 30. anagram0.py + works + didn’t take long to write
  31. 31. Python 2.7 FTW!
  32. 32. PyPy FTW FTW!
  33. 33. 52 x faster - Datastructures FTW!
  34. 34. What are you doing?
  35. 35. And now for something completely different….
  36. 36. Variations on an almost trivial sum….
  37. 37. Tools

×