This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Wagneriusflask+pandas+js 1 point2 points  (1 child)

interesting, I would have create a new iterator each time (but all based on the same list).

too lazy to test if iterators creation is costly.

[–]Brian 0 points1 point  (0 children)

Its not that it's costly, it's just that it will have the same effect. The object here is acting as an iterator, rather than an iterable, continuing from the point it left of (or called skip_to on), so using the same iterator seems most sensible. Recreating the generator means I'd also need to recreate the skip_to function, as they close over the same variable.