Use Python Built-in Functions to Speed your Code

Don’t create your own function if there is already a built-in Python function for that task. Built-in functions like sum, max, filter, map, etc are implemented in C so they are very efficient. Use them if you can.

Above is the comparison between the speed of using a built-in sum and the speed of using a custom sum. A little bit different in speed matters when you work with a large array.

Find a full list of Python built-in functions here.

Scroll to Top