[pypy-dev] Integer division

2017-05-31 Thread Tuom Larsen
Dear list! I noticed that integer division (`//`) is slower than floating-point division and integer cast. For example: from __future__ import division from time import time t = time() for i in range(1, 1): for j in range(1, 1): # k = i//j # 2.12 second

Re: [pypy-dev] round

2017-05-26 Thread Tuom Larsen
Created at https://bitbucket.org/pypy/pypy/issues/2563/slow-round Thank you for the explanation! On Fri, May 26, 2017 at 10:34 PM, Armin Rigo wrote: > Hi Tuom, > > On 26 May 2017 at 19:04, Tuom Larsen wrote: >> I noticed that `round` seem to run very slow. Is this a known issue

[pypy-dev] round

2017-05-26 Thread Tuom Larsen
Dear list! I noticed that `round` seem to run very slow. Is this a known issue or should I file an bug report? Or am I missing something? from timeit import timeit print timeit('int(sqrt(123.456)+0.5)', 'from math import sqrt') print timeit('int(round(sqrt(123.456)))', 'from math impo

Re: [pypy-dev] Sorting structs

2016-10-03 Thread Tuom Larsen
anks for the report! > > Cheers, > > Carl Friedrich > > > On 26/09/16 22:57, Tuom Larsen wrote: >> Dear list! >> >> I stumbled upon a problem and I was wondering if someone would by so >> kind and explain to me what is going on. >> >> The pr

Re: [pypy-dev] Sorting structs

2016-10-03 Thread Tuom Larsen
igger/smaller lists to see how they > behave. (also warming up both jit engines might be necessary) > > > On Mon, Sep 26, 2016 at 10:57 PM, Tuom Larsen wrote: >> >> Dear list! >> >> I stumbled upon a problem and I was wondering if someone would by so >> kin

[pypy-dev] Sorting structs

2016-09-26 Thread Tuom Larsen
Dear list! I stumbled upon a problem and I was wondering if someone would by so kind and explain to me what is going on. The problem is sorting 2 000 000 points by `x` coordinate: from random import random from time import time class point(object): def __init__(self, x, y):

Re: [pypy-dev] Shift and typed array

2016-04-04 Thread Tuom Larsen
> On Mon, Apr 4, 2016 at 3:53 PM, Tuom Larsen wrote: >> So other than numpy, do you think: >> >> a[0] = (2**63 << 1) & (2**64 - 1) >> >> is the best way I can do? >> >> On Mon, Apr 4, 2016 at 3:52 PM, Tuom Larsen wrote: >>> Yes, I

Re: [pypy-dev] Shift and typed array

2016-04-04 Thread Tuom Larsen
So other than numpy, do you think: a[0] = (2**63 << 1) & (2**64 - 1) is the best way I can do? On Mon, Apr 4, 2016 at 3:52 PM, Tuom Larsen wrote: > Yes, I just want to write code which is portable (as for example that > `& ...`) but still favors PyPy. > > On M

Re: [pypy-dev] Shift and typed array

2016-04-04 Thread Tuom Larsen
t;> so numpy64 will give you wrap-around arithmetics. What else are you >>> looking for? :-) >>> >>> On Mon, Apr 4, 2016 at 3:38 PM, Tuom Larsen wrote: >>>> You mean I should first store the result into numpy's `int64`, and >>>> then to `ar

Re: [pypy-dev] Shift and typed array

2016-04-04 Thread Tuom Larsen
ooking for? :-) > > On Mon, Apr 4, 2016 at 3:38 PM, Tuom Larsen wrote: >> You mean I should first store the result into numpy's `int64`, and >> then to `array.array`? Like: >> >> x = int64(2**63 << 1) >> a[0] = x >> >> Or: >>

Re: [pypy-dev] Shift and typed array

2016-04-04 Thread Tuom Larsen
c. > > Feel free to complain "no, I want real types that I can work with" :-) > > Cheers, > fijal > > On Mon, Apr 4, 2016 at 3:10 PM, Tuom Larsen wrote: >> Hello! >> >> Suppose I'm on 64-bit machine and there is an `a = arrar.array('L',

[pypy-dev] Shift and typed array

2016-04-04 Thread Tuom Larsen
Hello! Suppose I'm on 64-bit machine and there is an `a = arrar.array('L', [0])` (item size is 8 bytes). In Python, when an integer does not fit machine width it gets promoted to "long" integer of arbitrary size. So this will fail: a[0] = 2**63 << 1 To fix this, one could instead write:

Re: [pypy-dev] Automatic SIMD vectorization

2015-10-20 Thread Tuom Larsen
Awesome, thank you! On Tue, Oct 20, 2015 at 4:41 PM, Richard Plangger wrote: > Hi, > > glad you liked the post! See the answers below... > > On 10/20/2015 04:20 PM, Tuom Larsen wrote: >> Hello all! >> >> I just read with great interest the blog post "Auto

[pypy-dev] Automatic SIMD vectorization

2015-10-20 Thread Tuom Larsen
Hello all! I just read with great interest the blog post "Automatic SIMD vectorization support in PyPy". Please, I have a few questions: - Does regular Python code benefit from the vectorization? I mean, the article on one hand says "it is not specifically targeted for the NumPy library" but on

[pypy-dev] "PyPy lets us go where we need to"

2015-10-16 Thread Tuom Larsen
Dead list, not sure if this is the right place to share but there is a presentation by a Mozilla dev being currently discussed on Reddit where PyPy received quite some praise: https://www.reddit.com/r/golang/comments/3oztwi/from_python_to_go_and_back_again_mozilla_dev/ Cheers! __

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 nic

Re: [pypy-dev] Crash in JIT

2015-10-07 Thread Tuom Larsen
can try the nightly? > > On Wed, Oct 7, 2015 at 2:14 PM, Tuom Larsen wrote: >> Hello! >> >> I have a fairly long code here so I have yet to distill a short test >> case but I started to get a crash in 2.6.0 (I never saw this kind of >> error in earlier versions)

[pypy-dev] Crash in JIT

2015-10-07 Thread Tuom Larsen
Hello! I have a fairly long code here so I have yet to distill a short test case but I started to get a crash in 2.6.0 (I never saw this kind of error in earlier versions). Is there anything I can do to give you more helpful information besides the following error message? RPython traceback: Fi

Re: [pypy-dev] Size limit

2015-10-07 Thread Tuom Larsen
the heuristic to always trace a function that's the only one > maybe though > > On Tue, Oct 6, 2015 at 7:32 PM, Tuom Larsen wrote: >> Hello! >> >> I have a piece of auto-generated code and I noticed that if a function >> has more than certain number of expressio

[pypy-dev] Size limit

2015-10-06 Thread Tuom Larsen
first line it drops to 5.3 seconds. Thanks, Tuom Larsen def f(x): a0 = x*0.1; a1 = x*0.1; a2 = x*0.2; a3 = x*0.3; a4 = x*0.4 a5 = x*0.5; a6 = x*0.6; a7 = x*0.7; a8 = x*0.8; a9 = x*0.9 b0 = x*0.1; b1 = x*0.1; b2 = x*0.2; b3 = x*0.3; b4 = x*0.4 b5 = x*0.5; b6 =

Re: [pypy-dev] Copy of list

2015-09-29 Thread Tuom Larsen
, thanks a lot once more! On Tue, Sep 29, 2015 at 9:25 AM, Armin Rigo wrote: > 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 pe

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: > >>

[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