Re: [pypy-dev] Copy of list

2015-10-07 Thread Tuom Larsen
So I just tried it with the latest nightly build and `[:]` is now even a bit faster than `list()`! Thank you once more! On Tue, Sep 29, 2015 at 12:27 PM, Tuom Larsen wrote: > Hi Armin, > > thanks a lot, both for the explanation and the fix! I will try it soon. > > Have a nice day! > > Tuom > > PS

Re: [pypy-dev] Copy of list

2015-09-29 Thread Tuom Larsen
Hi Armin, thanks a lot, both for the explanation and the fix! I will try it soon. Have a nice day! Tuom PS: The speed difference came from larger piece of code, which I tried to reproduce in "minimal viable test case". Hence that `timeit`, where it showed up as well. But in any case, thanks a l

Re: [pypy-dev] Copy of list

2015-09-29 Thread Armin Rigo
Hi Tuom, On Tue, Sep 29, 2015 at 7:31 AM, Tuom Larsen wrote: > Please, let me rephrase my question: currently I use `[:]` because it > is faster in CPython (0.131 usec vs 0.269 usec per loop). I almost > don't mind changing it to `list()` because of PyPy but I was wondering > what do PyPy develop

Re: [pypy-dev] Copy of list

2015-09-28 Thread Tuom Larsen
Hello Armin, Thanks for the answer! On Mon, Sep 28, 2015 at 8:17 PM, Armin Rigo wrote: > > In addition to the other comments, this is not testing what you think > it is: 'range(100)' returns a list optimized for being a range, and > 'list(range(100))' does it too. You can see it like this: > >>

Re: [pypy-dev] Copy of list

2015-09-28 Thread Armin Rigo
Hi Tuom, On Mon, Sep 28, 2015 at 3:57 PM, Tuom Larsen wrote: > 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 In addition to the other comments, this is not tes

Re: [pypy-dev] Copy of list

2015-09-28 Thread Oscar Benjamin
On Mon, 28 Sep 2015 at 14:57 Tuom Larsen wrote: > 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 time

Re: [pypy-dev] Copy of list

2015-09-28 Thread Vincent Legoll
Hello, is your code actually such a heavy list-copy-through-slicing user ? This question is independent from pypy's eventual desire to speed this python "idiom", though. I myself was using it, but went to use list(), as that look more natural, to my eyes, but that's a matter of taste anyways, I

[pypy-dev] Copy of list

2015-09-28 Thread Tuom Larsen
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.073