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.“
@PaulJurczak Жыл бұрын
@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.
@nescius2 Жыл бұрын
40:00 ...don't sacrifice readability for -small performance gains- list comprehensions
@barmalini3 күн бұрын
comprehensions are fine, you just need to write one or two yourself to get familiar with the format and then you feel like missing them