Re: [pypy-dev] Optimize constant float division by multiplication?

2014-11-07 Thread Toni Mattis
Hi Armin, > Do you mind if I merge this branch 'float-ops' into the > standard repo? I'm totally fine with a merge. Best regards, Toni ___ pypy-dev mailing list pypy-dev@python.org https://mail.python.org/mailman/listinfo/pypy-dev

Re: [pypy-dev] Optimize constant float division by multiplication?

2014-11-06 Thread Toni Mattis
19:08 schrieb Armin Rigo: > Hi Toni, > > On 6 November 2014 18:29, Toni Mattis > wrote: >> thanks for the advice. I tried what Armin proposed and like to share my >> results with you: >> >> https://bitbucket.org/amintos/pypy/commits/937254cbc554adfb748e3b5eeb44b

Re: [pypy-dev] Optimize constant float division by multiplication?

2014-11-06 Thread Toni Mattis
Hi all, thanks for the advice. I tried what Armin proposed and like to share my results with you: https://bitbucket.org/amintos/pypy/commits/937254cbc554adfb748e3b5eeb44bf765d204b9d?at=default Keeping in mind what Steve and Maciej pointed out, I restricted the optimization to floats that are "no

[pypy-dev] Optimize constant float division by multiplication?

2014-11-05 Thread Toni Mattis
Hello, I discovered that PyPy's JIT generates "DIVSD" instructions on xmm registers when dividing a float by a constant C. This consumes an order of magnitude more CPU cycles than the corresponding "MULSD" instruction with a precomputed 1/C. I know that only powers of two have an exact reciprocal

[pypy-dev] Calling lambdas inside loop causes significant slowdown

2014-08-04 Thread Toni Mattis
Hi, I'm trying to figure out the fastest way in PyPy to introduce abstractions into loops, e.g. refactoring the following code: def sum_direct(data): s = 0 for i in data: if i < 5: s += i + 1 return s to something like: def sum_lambda(data): filter_func =