try:
    __builtin__.profile
except AttributeError:

    def profile(func):
        return func
__builtin__.profile = profile
python profiling using line_profiler - clever way to remove @profile statements on-the-fly?