Sebastian Witowski - Writing Faster Python 3

  Рет қаралды 3,208

PyCon PL

PyCon PL

Күн бұрын

Strona PyConPL: pl.pycon.org
FB: pl.pycon.org/
Linkedin: / pyco. .
Twitter: / pyconpl
Did you know that Python preallocates integers from -5 to 257? Reusing them 1000 times, instead of allocating memory for a bigger integer, can save you a couple milliseconds of code’s execution time. If you want to learn more about this kind of optimizations then, … well, probably this presentation is not for you :) Instead of going into such small details, I will talk about more “sane” ideas for writing faster code.
After a brief overview of how you can speed up your Python code in general, we will dig into source code optimization. I will show you some simple and fast ways of measuring the execution time of your code, and then we will discuss examples of how to improve some common code structures.
You will see:
* The fastest way of removing duplicates from a list
* How much faster your code is when you reuse the built-in functions instead of trying to reinvent the wheel
* What is faster than the “for loop”
* If the lookup is faster in a list or a set
* When it’s better to beg for forgiveness than to ask for permission
Sebastian Witowski
Sebastian is a Python consultant based in Poland. He started his journey with programming as a software developer at CERN, where he fell in love with Python (and teaching). Now he is helping companies untangle their complicated architecture and build all sorts of interesting Python projects.
In his spare time, he talks about Python, best practices in programming, and productivity.

Пікірлер: 3
@jimratliff
@jimratliff 10 ай бұрын
The best talk I have ever seen on actionable ways to optimize Python source code. Particularly: showing the trade-offs and that the answer is sometimes “it depends.“
@nescius2
@nescius2 8 ай бұрын
40:00 ...don't sacrifice readability for -small performance gains- list comprehensions
@PaulJurczak
@PaulJurczak 8 ай бұрын
@10:47 You are timing both the compilation and execution of Numba example. It is unfair. Numba is able to replace the loop with a formula you show later (Python 3.11, Numba 0.56.4). The execution is extremely fast. On my PC [ms]: Python loop 51.6, NumPy 3.7 and Numba 0.00022! A more "fair" example, i.e. forcing each version to run the loop, would be `total += x%9`. Timing of one million iterations [ms]: Python loop 42.6, NumPy 7.3 and Numba 0.77! Numba is still an order of magnitude faster.
Iron Chin ✅ Isaih made this look too easy
00:13
Power Slap
Рет қаралды 36 МЛН
EVOLUTION OF ICE CREAM 😱 #shorts
00:11
Savage Vlogs
Рет қаралды 8 МЛН
MISS CIRCLE STUDENTS BULLY ME!
00:12
Andreas Eskander
Рет қаралды 19 МЛН
Sebastian Witowski - Writing faster Python
24:10
EuroPython Conference
Рет қаралды 100 М.
Talk - Trey Hunner: Python Oddities Explained
25:45
PyCon US
Рет қаралды 8 М.
The Worst Programming Language Ever - Mark Rendle - NDC Oslo 2021
1:00:41
NDC Conferences
Рет қаралды 1,3 МЛН
python is removing the GIL! (PEP 703) (advanced) anthony explains #550
24:04
All Python Syntax in 25 Minutes - Tutorial
24:59
Beau
Рет қаралды 32 М.
PyO3: From Python to Rust and Back Again (with David Hewitt)
1:34:30
Developer Voices
Рет қаралды 9 М.
Don't use VSCode
35:31
PyCon South Africa
Рет қаралды 217 М.