Talk - Anthony Shaw: Write faster Python! Common performance anti patterns

  Рет қаралды 31,430

PyCon US

PyCon US

Күн бұрын

Пікірлер: 10
@SuperGrimmy
@SuperGrimmy 2 жыл бұрын
It's amazing what you learn over time when hyper-optimizing python code. We've been optimizing the python arcade library a lot over the last two years managing in some cases to boost speed by 10x in certain locations just with pure python. One example that shocked me is how slow weak references or containers for weak references like weak sets are. Using that as a container for sprites was 4-5x slower than a plain list. Also dataclasses was a trap for us. When you have 10-16ms per frame, every tiny things really starts to matter. The function call overhead is not a joke. Even things like a @property can slow down things.
@ZuLuuuuuu
@ZuLuuuuuu 2 жыл бұрын
Great talk. The point Anthony mentioned about profiling your code to discover the exact places where your code slows down is very important. I frequently see people trying to optimize insignificant parts of their code just because they _guessed_ what was slowing down their code, instead of profiling it. Also, it is important to ask yourself if you really need to optimize your code, you might be surprised that sometimes simple and theoretically inefficient implementations can be fast enough.
@_elkd
@_elkd 2 жыл бұрын
Thanks Anthony for the talk and benchmarking with Pypy as well. I run Pypy where I can, my biggest fear with microoptimizing is that sometimes you gain performance with CPython but then Pypy comes along with surprises. The best part of this talk is that in all 4 cases CPython is happy and so is Pypy. But when you start to replace builtins, do some C level twerks, it appears Pypy just love naive Python code.
@juliejones8785
@juliejones8785 2 жыл бұрын
It would be nice to see what kind of tests that you ran to compare performance of Tuple, Dataclass and class. I was surprised at your results and wonder if typical usage would be inline with your tests.
@stephenaustin3026
@stephenaustin3026 2 жыл бұрын
CPython Internals is a very good book. But it would be a GREAT BOOK if only it had an index.
@AnthonyShaw
@AnthonyShaw 2 жыл бұрын
Thanks! And I will ask Dan again about getting an index.
@minyakonga8897
@minyakonga8897 2 жыл бұрын
what i learned: before optimizing your code, you need a comparison, thus each time you optimize, run the comparison and check if it speeds up.
@louismaddox6151
@louismaddox6151 2 жыл бұрын
wait I want some socks
@cat-.-
@cat-.- 2 жыл бұрын
First anti pattern I want you all to remember: instead giving files name ending in .py, you should end it with .c
@Tutez
@Tutez 2 жыл бұрын
why?
Talk - Trey Hunner: Python Oddities Explained
25:45
PyCon US
Рет қаралды 9 М.
Wednesday VS Enid: Who is The Best Mommy? #shorts
0:14
Troom Oki Toki
Рет қаралды 50 МЛН
Sigma girl VS Sigma Error girl 2  #shorts #sigma
0:27
Jin and Hattie
Рет қаралды 124 МЛН
Talk: Conor Hoekstra - Beautiful Python Refactoring
30:05
PyCon US
Рет қаралды 24 М.
How Much FASTER Is Python 3.13 Without the GIL?
10:00
ArjanCodes
Рет қаралды 188 М.
Arenas, strings and Scuffed Templates in C
12:28
VoxelRifts
Рет қаралды 108 М.
Talk: Anthony Shaw - Why is Python slow?
32:52
PyCon US
Рет қаралды 22 М.
10 Nooby Mistakes Devs Often Make In Python
24:31
Indently
Рет қаралды 72 М.
UV and Ruff: Next-gen Python Tooling
56:54
Matt Layman
Рет қаралды 7 М.