def profile(func, stream=None):
    """
    Decorator that will run the function and print a line-by-line profile
    """
    def wrapper(*args, **kwargs):
        prof = LineProfiler()
        val = prof(func)(*args, **kwargs)
        show_results(prof, stream=stream)
        return val
    return wrapper
def profile ( func , stream = None ) : def wrapper ( * args , ** kwargs ) : prof = LineProfiler ( ) val = prof ( func ) ( * args , ** kwargs ) show_results ( prof , stream = stream ) return val return wrapper
Decorator that will run the function and print a line-by-line profile