Message383485
Sorry for intruding, but I thought I'd offer some rudimentary, non-scientific benchmarks for this:
[MSC v.1928 32 bit (Intel)] on win32 # a debug build of python, no compiler optimizations
import timeit
# gen comp
timeit.timeit("''.join(str(_) for _ in range(1000))", number=10000)
11.154560299999957
# list comp
timeit.timeit("''.join([str(_) for _ in range(1000)])", number=10000)
9.987510899999961
The list comp is slightly faster than the gen comp. Interestingly, if one were to use python -m timeit instead, the gen comp would show better results since it has a better 'best of 5' timing. IMO, total time is a more accurate representation than best of 5 since the latter gets skewed by outliers. |
|
Date |
User |
Action |
Args |
2020-12-21 03:50:30 | kj | set | recipients:
+ kj, eric.smith, josh.r, samuelmarks |
2020-12-21 03:50:30 | kj | set | messageid: <1608522630.73.0.842939124155.issue42699@roundup.psfhosted.org> |
2020-12-21 03:50:30 | kj | link | issue42699 messages |
2020-12-21 03:50:30 | kj | create | |
|