Ken Jin <kenjin4...@gmail.com> added the comment:

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.

----------
nosy: +kj

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue42699>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to