3 ms·
That is a common misconception. Moving to iterators adds a function call while list creation in C is quite fast. Every case has to be tested for performance.
by elyase 13y ago
That is a common misconception. Moving to iterators adds a function call while list creation in C is quite fast. Every case has to be tested for performance.
- mctx 13y agoI always thought the reason iterators are used in preference to lists was due to the memory advantages, not the performance.
- ekimekim 13y agoThere's also flexibility improvements to do with lazy evaluation, and it makes the Twisted guys not hate you.
- merlincorey 13y agoThe memory advantages are key to performance when you have a non-trivially sized dataset, in my experience.
- merlincorey 13y agoIn my experience, building a non-trivially transformed sequence with the builtin C-backed list and list comprehensions vs iterators and generators, the iterators and generators win. Maybe I'm doing crazy stuff, though!