List vs generator comprehension speed with join function
So I got these examples from the official documentation. https://docs.python.org/2/library/timeit.html What exactly makes the first example (generator expression) slower than the second (list comprehension)? >>> timeit.timeit('"-".join(str(n) for n in range(100))', number=10000) 0.8187260627746582 >>> timeit.timeit('"-".join([str(n) for n in range(100)])', number=10000) 0.7288308143615723 Answers: Thank you for visiting the Q&A section on Magenaut. Please note that all the … Read more