I noticed that list creation is faster than tuple in Python 3.14. On my machine, the difference starts when the size is ~10.
This is quite interesting. How was it achieved? Isn’t it possible to apply the same optimization to tuple too?
I noticed that list creation is faster than tuple in Python 3.14. On my machine, the difference starts when the size is ~10.
This is quite interesting. How was it achieved? Isn’t it possible to apply the same optimization to tuple too?
Could you share more details, like the code you measured (there are multiple ways to create lists and tuples) and how you measured and what the results were? Also, did it differ in previous Python versions?
I myself looked into something like that as well, comparing these four:
1. list(iterable)
2. [*iterable]
3. tuple(iterable)
4. (*iterable,)
If I remember correctly, 2 was faster then 1, but 3 was faster than 4, which I found odd. I don’t remember where I ended up with it…
Did that again now, with iterable = itertools.repeat(None, 10**6):
3.01 ± 0.03 ms list(iterable)
2.98 ± 0.02 ms [*iterable]
3.58 ± 0.06 ms tuple(iterable)
5.95 ± 0.09 ms (*iterable,)
Python: 3.13.0 (main, Nov 9 2025, 11:53:23) [GCC 15.2.1 20250813]
from timeit import timeit
from statistics import mean, stdev
import random
import sys
setup = '''
from itertools import repeat
iterable = repeat(None, 10**6)
'''
codes = [
'list(iterable)',
'[*iterable]',
'tuple(iterable)',
'(*iterable,)',
]
times = {c: [] for c in codes}
for _ in range(100):
for c in random.sample(codes, len(codes)):
t = timeit(c, setup, number=1)
times[c].append(t)
for c in codes:
ts = [t * 1e3 for t in sorted(times[c])[:5]]
print(f'{mean(ts):5.2f} ± {stdev(ts):3.2f} ms ', c)
print('\nPython:', sys.version)
([*iterable] being faster than list(iterable) was for short iterables, where [*iterable] benefits from being syntax and thus getting handled by the interpreter directly.)
Anyway, I think I vaguely remember finding that tuple creation was optimized for short tuples because that’s the typical use case. You don’t usually put many objects into a tuple, you’d usually use a list for that. And optimizing for short cases can hurt for large cases.