Say I want to test two heap implementations like this:
def test_heap():
for i in range(15):
test_list = random.sample(range(10000), 1000)
print(timeit("h = heap1(test_list)", "setup"))
print(timeit("h = heap2(test_list)", "setup"))
if __name__ == "__main__":
test_heap()
I don't want to put whatever is in test_heap
into the main, what should the setup statement be so I can import test_list
into timeit
?