Skip to content

Instantly share code, notes, and snippets.

@terror
Last active June 27, 2020 21:38
Show Gist options
  • Save terror/d6d51cd8d157fb93ddd05132e7f2c0af to your computer and use it in GitHub Desktop.
Save terror/d6d51cd8d157fb93ddd05132e7f2c0af to your computer and use it in GitHub Desktop.
Python queue standard lib
import queue
items = [1,2,3,4,5]
q = queue.Queue()
# Enqueue elements
for i in items:
q.put(i)
# Dequeue and return element from the queue
item = q.get()
# Get size of queue (int)
q_size = q.qsize()
# Check if empty queue (bool)
is_empty = q.empty()
# Check if queue is full (bool)
is_full = q.full()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment