Python Comprehension Is Not Fast

Author: Szymon Lipiński
Published at: 2016-10-12

In the previous blog post I have presented results of benchmarking list comprehensions, and maps in Python.

The results looked fine, however there was one thing that I couldn’t stop thinking about. The memory overhead, and the huge execution time.

The process wanted to use the 50MB from the beginning. Then it had just to iterate through a list of integers (which are small). The number of integers is also small (only 1M). Then it had to make 1M divisions to find the even numbers, and square it (making 0.5M multiplications, and 0.5M additions).

Why did it take 1.5 minute?