3 ms·
... Except generators and comprehensions are often faster than for loops in your hot path. Apart from that... What's readable tends to be the best option.
by shakna 10y ago
... Except generators and comprehensions are often faster than for loops in your hot path.
Apart from that... What's readable tends to be the best option.
- swsieber 10y agoI think the Python community considers list comprehension more readable than loops. And writing generators allows you to write simple code with them. I don't consider generators to be fancy - just a tool to pull out complexity into a small area and make the rest of the code readable.