I've recently encountered an article that showed some ways to speed up one's Python code. Some of these methods seemed rather peculiar, so I decided to do some extra complex data analysis to try to understand whether these methods actually work.
Python version: 3.7.1
Here's a quick summary of the methods proposed in that article that I found odd.
The article said that, since for
loops are "dynamic" (not sure what this means), they're slower than while
loops. I compared the following two loops and found that, on average, the for
loop was about 2.5 times faster than the corresponding while
loop: