Re: [sage-devel] Re: PEP idea: unary division

2018-08-16 Thread David Roe
On Fri, Jun 3, 2016 at 2:07 PM Jeroen Demeyer wrote: > On 2016-06-03 19:55, Simon King wrote: > > Note that testing "a==1" goes through the coercion model as well. > > Sure, but that's not what you want to do. I propose to test something like > > (isinstance(a, int) and a == 1) or (type(a) is Int

Re: [sage-devel] Re: PEP idea: unary division

2016-06-05 Thread Vincent Delecroix
With #20731 and #20777 merged I got the more interesting sage: %timeit U(200,100) 1 loop, best of 3: 169 ms per loop sage: %timeit V(200,100) 1 loop, best of 3: 196 ms per loop sage: %timeit W(200,100) 1 loop, best of 3: 610 ms per loop On 04/06/16 02:03, Nils Bruin wrote: Hopefully

Re: [sage-devel] Re: PEP idea: unary division

2016-06-05 Thread Vincent Delecroix
see #17692... and note that #20731 will speed up the second case. On 04/06/16 02:03, Nils Bruin wrote: Hopefully a little more robust benchmark: sage: cython(""" : from sage.rings.integer import Integer : from sage.rings.integer cimport Integer : from sage.rings.rational import Rati

Re: [sage-devel] Re: PEP idea: unary division

2016-06-03 Thread Nils Bruin
Hopefully a little more robust benchmark: sage: cython(""" : from sage.rings.integer import Integer : from sage.rings.integer cimport Integer : from sage.rings.rational import Rational : from sage.rings.rational cimport Rational : def U(a, n): : cdef Integer A=a :

Re: [sage-devel] Re: PEP idea: unary division

2016-06-03 Thread Jeroen Demeyer
On 2016-06-03 19:10, Vincent Delecroix wrote: I am not sure we want to special case 1 in all multiplication/division. Well, there are a lot of places in Sage where we use ~x currently. This means that there is a lot of demand for computing 1/x. -- You received this message because you are su

Re: [sage-devel] Re: PEP idea: unary division

2016-06-03 Thread Jeroen Demeyer
On 2016-06-03 19:55, Simon King wrote: Note that testing "a==1" goes through the coercion model as well. Sure, but that's not what you want to do. I propose to test something like (isinstance(a, int) and a == 1) or (type(a) is Integer and a == 1) but then more efficiently. That should be pret

Re: [sage-devel] Re: PEP idea: unary division

2016-06-03 Thread Simon King
Am Freitag, 3. Juni 2016 19:11:01 UTC+2 schrieb vdelecroix: > > But using division or multiplication go through the coercion model. I am > not sure we want to special case 1 in all multiplication/division. It is > likely to slow even more our slow coercion model... > > Note that testing "a==1"

Re: [sage-devel] Re: PEP idea: unary division

2016-06-03 Thread Vincent Delecroix
1 is already special cased in sage: FreeGroup('ab')(1) 1 But using division or multiplication go through the coercion model. I am not sure we want to special case 1 in all multiplication/division. It is likely to slow even more our slow coercion model... Vincent On 03/06/16 18:43, mmarco wr

Re: [sage-devel] Re: PEP idea: unary division

2016-06-02 Thread William Stein
On Thu, Jun 2, 2016 at 1:33 PM, Volker Braun wrote: > I'm guessing that this won't fly with upstream ;-) > > Is it really faster? A new __unary_div__ method everywhere? Is it really > faster than special-casing the 1/x case in __div__? According to my unscientific benchmark just now there seems