28 Sep
2015
28 Sep
'15
1:57 p.m.
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!
3095
Age (days ago)
3104
Last active (days ago)
7 comments
4 participants
participants (4)
-
Armin Rigo
-
Oscar Benjamin
-
Tuom Larsen
-
Vincent Legoll