About Measuring Function Execution Time with Timeit

When using timeit to measure function execution time, you will need to use the second parameter for the imports, for example:

import timeit

def function_in_question():
    ...

if __name__ == "__main__":
    print(timeit.timeit(
        """function_in_question()""",
        """from __main__ import function_in_question""",
    ))

Tips and Tricks Programming Optimization Python 3