2 ms·
Not very Pythonic for i in range(len(records)): scores[i] = score(records[i]) Better for i, record in enumerate(records): scores[i] = score(recor
by gabrielsroka 3mo ago
Not very Pythonic
for i in range(len(records)):
scores[i] = score(records[i])
Better
for i, record in enumerate(records):
scores[i] = score(record)
Best
scores = [score(record) for record in records]
Raymond Hettinger (Python core dev): https://gist.github.com/bespokoid/205efd91546ddb16b210678830fa9eeb https://gist.github.com/bespokoid/205efd91546ddb16b210678830...
- soumik15630m 3mo agoSure those are good designs... But Lucen is not about "here's a nicer way to write loops," it's "you shouldn't have to touch the loop you already have."..... showing Lucen parallelize the ugly version is the point.
- gabrielsroka 3mo agoI get it, but I'd never write it like that. Does it support list comprehensions, etc?
- soumik15630m 3mo agonot currently - currently lucen runs on marked for statement loop but yeah it's a cleaner one to add ...just not the surface i started with