3 ms·
range(10) doesn't properly demonstrate the material differences between generators and lists. Like posted elsewhere, tee is an appropriate solution that preser
by wyldfire 8y ago
range(10) doesn't properly demonstrate the material differences between generators and lists.
Like posted elsewhere, tee is an appropriate solution that preserves the generator's benefits over a list. It's too bad that the example is so synthetic.
- shmageggy 8y agoOne downside of both solutions is that they both traverse the list twice, which could be expensive when we're talking about real data and not toy problems.