@optional_args
def line_profile(func):
    'Q&D helper to line profile the function and spit out stats\n    '
    import line_profiler
    prof = line_profiler.LineProfiler()

    @wraps(func)
    def _wrap_line_profile(*args, **kwargs):
        try:
            pfunc = prof(func)
            return pfunc(*args, **kwargs)
        finally:
            prof.print_stats()
    return _wrap_line_profile
Q&D helper to line profile the function and spit out stats
@optional_args
def line_profile(func):
    '\n    '
    import line_profiler
    prof = line_profiler.LineProfiler()

    @wraps(func)
    def _wrap_line_profile(*args, **kwargs):
        try:
            pfunc = prof(func)
            return pfunc(*args, **kwargs)
        finally:
            prof.print_stats()
    return _wrap_line_profile