4 ms·
If anything this is a testament to how slow python can be, and most importantly how easily it pushes you to write miserably unoptimized code. It could be a bit
by thanzex 4y ago
If anything this is a testament to how slow python can be, and most importantly how easily it pushes you to write miserably unoptimized code.
It could be a bit overkill, but whenever I'm writing code on top of optimizing data structures and memory allocations I always try to minimize the use of if statements to reduce the possibility of branch prediction errors.
Seeing woefully unoptimized python code being used in a production environment just breaks my heart.
- baobob 4y agothe CPU branch predictor is so many levels down it will have almost no discernible effect on anything you might call a branch in Python code. Even a statement like "a = 1" likely executes a few tens if not a few hundred branches That is not to say aiming for generally unbranchy code is not a good thing - that often implies well designed code and well chosen data structures anyway