O'Reilly logo
  • Brandon Reeser thinks this is interesting:

Example 2-5. Defining a decorator to automate timing measurements
from functools import wraps

def timefn(fn):
    def measure_time(*args, **kwargs):
        t1 = time.time()
        result = fn(*args, **kwargs)
        t2 = time.time()
        print ("@timefn:" + fn.func_name + " took " + str(t2 - t1) + " seconds")
        return result
    return measure_time

def calculate_z_serial_purepython(maxiter, zs, cs):


Cover of High Performance Python


use this for next week's rollout