File: class/Workbook/Exercises/Lab5/stacktime.py

import time
import stack1, stack2

def run(n, module):
    start = time.clock()
    for i in range(n): 
        module.push('spam' + `i`)
    print module.top(), module.item(1)
    for i in range(n): 
        module.pop()
    return time.clock() - start

print 'stack1:', run(2500, stack1)
print 'stack2:', run(2500, stack2)



[Home page] Books Code Blog Python Author Train Find ©M.Lutz