Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
YokoZar
on July 10, 2014
|
parent
|
context
|
favorite
| on:
Anti-Patterns in Python Programming
Wouldn't chain(*words) require unpacking all of words before feeding it into the chain function, storing a second copy of the word list in memory?
rbonvall
on July 10, 2014
[–]
Yes it would, but I don't care about these small efficiencies, say 97% of the time ;)
The lazy version in Python 3 would be this one:
list(chain(*map(iter, words)))
For Python 2 one has to use itertools.imap instead of map.
Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: