Deque implemenation in python