Skip to content

Instantly share code, notes, and snippets.

@josepsmartinez
Created June 12, 2022 23:52
Show Gist options
  • Save josepsmartinez/1de72a69496208491c184589542b9292 to your computer and use it in GitHub Desktop.
Save josepsmartinez/1de72a69496208491c184589542b9292 to your computer and use it in GitHub Desktop.
Exhaust Python iterator
# as in https://stackoverflow.com/a/36763172/4449273
import collections
def exhaust_iterator(it):
collections.deque(it, maxlen=0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment