hotshotProfilers = {} def hotshotit(func): def wrapper(*args, **kw): import hotshot global hotshotProfilers prof_name = func.func_name+".prof" profiler = hotshotProfilers.get(prof_name) if profiler is None: profiler = hotshot.Profile(prof_name) hotshotProfilers[prof_name] = profiler return profiler.runcall(func, *args, **kw) return wrapper