Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to Profile a Python Program - Block 5
Filename: example_2.py
Line # Mem usage Increment Occurences Line Contents
============================================================
3 18.6 MiB 18.6 MiB 1 @profile
4 def wasteful_sum_function() -> int:
5 19.1 MiB 0.5 MiB 10003 return sum([x**2 for x in range(10**4)])
Filename: example_2.py
Line # Mem usage Increment Occurences Line Contents
============================================================
7 19.1 MiB 19.1 MiB 1 @profile
8 def resource_efficient_sum_function() -> int:
9 19.1 MiB 0.0 MiB 20003 return sum((x**2 for x in range(10**4)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment