Oct-21-2019, 10:53 AM
Define two functions f1 and f2 such that,
f1 returns a list of squares of first 200000 natural numbers using list comprehension.
f2 returns a generator that computes squares of first 200000 natural numbers.
Perform profiling of both the functions and which portions of a function consume more time for computing.
Hint : Make use of runctx method of cProfile module.
f1 returns a list of squares of first 200000 natural numbers using list comprehension.
f2 returns a generator that computes squares of first 200000 natural numbers.
Perform profiling of both the functions and which portions of a function consume more time for computing.
Hint : Make use of runctx method of cProfile module.