Skip to content

Instantly share code, notes, and snippets.

@nenetto
Created September 26, 2023 10:31
Show Gist options
  • Save nenetto/b6edec88ec18ba2392d4723debff7988 to your computer and use it in GitHub Desktop.
Save nenetto/b6edec88ec18ba2392d4723debff7988 to your computer and use it in GitHub Desktop.
Double-ended Queue, Ordered dictionaries, default dictionary
# Double-ended Queue
fifo = collections.deque()
fifo.append(1) # Producer
x = fifo.popleft() # Consumer
# OrderedDict
a = OrderedDict()
a[‘foo’] = 1
a[‘bar’] = 2
b = OrderedDict()
b[‘foo’] = ‘red’
b[‘bar’] = ‘blue’
for value1, value2 in zip(a.values(), b.values()):
print(value1, value2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment