On Thu, Aug 1, 2019 at 10:49 AM Eli Berkowitz firstname.lastname@example.org wrote:
In terms of an argument for why it should be included, for most Python users the itertools recipes remain unseen. I consider myself relatively fluent in Python (not compared to y'all of course) and hadn't seen them until I started this thread. If I had to hazard a guess, they're probably unused by 95%+ of the Python userbase. Having a function like consume as a builtin or part of a library widely increases visibility, and as it's a clean and efficient way of running an expression on a collection of data I think it's worth it especially as it has very little overhead.
Also, given that `consume_iterator` is already in CPython in the collections module as a special case for `collections.deque(..., maxlen=0)` (and maybe some other things), I'm guessing it would not be hard at all to add consume to the itertools module, though I'll be honest I have no idea how Python's underlying C code fits together at the module level.
You can open an issue at bugs.python.org to make consume() a top-level itertools function, but check it hasn't been asked for before.