Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
How to Profile a Python Program - Block 4
from memory_profiler import profile
def wasteful_sum_function() -> int:
return sum([x**2 for x in range(10**4)])
def resource_efficient_sum_function() -> int:
return sum((x**2 for x in range(10**4)))
if __name__ == '__main__':
#Profiling functions by executing them seperately
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment