Are there any standard library data structures for a queue that automatically requeues to the opposite end of the queue when an item is popped off the end? This feels like a common problem so I imagine that there could be a simple data structure that does this.
For example:
from collections import deque
from time import sleep
queue = deque([1, 2, 3, 4, 5, 6, 7, 8])
while True:
item = queue.pop()
queue.appendleft(item)
print(item)
sleep(5)
Is the above code actually optimal, or is there a better way to solve this problem?
Would it be better to just use a list and modify an index value each iteration of the loop to change which place in the list is accessed?