Fastest (most Pythonic) way to consume an iterator
问题 I am curious what the fastest way to consume an iterator would be, and the most Pythonic way. For example, say that I want to create an iterator with the map builtin that accumulates something as a side-effect. I don't actually care about the result of the map , just the side effect, so I want to blow through the iteration with as little overhead or boilerplate as possible. Something like: my_set = set() my_map = map(lambda x, y: my_set.add((x, y)), my_x, my_y) In this example, I just want to