Create a gist now

Instantly share code, notes, and snippets.

@danriti /
Last active Nov 22, 2017

What would you like to do?
Line Profiling in Python
from time import sleep
def so_slow(bar):
""" Simulate a slow function. """
return bar
def its_time_for_the_calculator(foo):
""" It's time for the calculator. """
if not isinstance(foo, int):
return None
a = []
for i in xrange(foo):
b = so_slow(a)
c = 0
for i in xrange(foo):
c += i
return None
def main():
print its_time_for_the_calculator(100000)
if __name__ == "__main__":

ckarany commented Feb 11, 2015

Where is "@Profile" decorator defined?

neara commented Jul 13, 2015


You have to call kernprof with the -l flag for the @Profile decorator to be recognized

What is

In the recent release we need not give we can just use kernprof

kernprof -l -v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment