Skip to content

Instantly share code, notes, and snippets.

  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save bilalozdemir/8f6de7e66be66bf642afe98d24d60055 to your computer and use it in GitHub Desktop.
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