'''Stack ADT.

Operations:
	pop: remove and return top item
        push(item): store item on top of stack
        is_empty: return whether stack is empty.
'''

class Stack:

    '''A last-in, first-out (LIFO) stack of items'''

    def __init__(self):
        '''A new empty Stack.'''
        self._data = []

    # this stack is implemented to push and pop at _data[0]!!!
        
    def pop(self):
        '''Remove and return the top item.'''
        return self._data.pop(0)
    
    def is_empty(self):
        '''Return whether the stack is empty.'''
        return len(self._data) == 0
    
    def push(self, o):
        '''Place o on top of the stack.'''
        self._data.insert(0,o)
        
if __name__  ==  '__main__':
    import time
    s = Stack()
    items = range(100000)

    # start the clock
    start = time.time()
    
    for i in items:
        s.push(i)
        
    for i in items:
        s.pop()
        
    end = time.time()
    print("It took ", end - start, "to push/pop", len(items), "items")
    
    
