[pypy-dev] Copy of list
Tuom Larsen
tuom.larsen at gmail.com
Mon Sep 28 15:57:22 CEST 2015
Dear PyPy developers!
In CPython, a common idiom to copy a list is to use slice, as in:
copy = original[:]
I noticed that under PyPy 2.6.0 it seems quite a bit slower than using
`list` constructor:
from timeit import timeit
print timeit('b = a[:]', 'a = list(range(100))') # 0.0732719898224
print timeit('b = list(a)', 'a = list(range(100))') # 0.00285792350769
Please, could some comment on what is the preferred way to copy a list
under PyPy? Should I try to avoid the "slice way"?
Thanks!
More information about the pypy-dev
mailing list