Hi Paul,

On 4/7/24 5:51 PM, Paul Eggert wrote:
> a.append should be faster, as it need not cons the singleton.

Thanks. Yes, that it is what I was trying to get at. But I didn't know
the correct wording. :)

Here is 'var.extend(["a"])' added to the simple timeit comparison:

>>> import timeit
>>> timeit.timeit(stmt='var += ["a"]', setup='var = []', number=100000000)
6.978962032000709
>>> timeit.timeit(stmt='var.extend(["a"])', setup='var = []', number=100000000)
6.58610403899911
>>> timeit.timeit(stmt='var.append("a")', setup='var = []', number=100000000)
1.8816217469993717

Collin

Reply via email to