Re: [Cython] Supporting cython.operator in C

2016-06-02 Thread Robert Bradshaw
On Thu, Jun 2, 2016 at 1:06 PM, Jeroen Demeyer wrote: > On 2016-06-02 21:12, Robert Bradshaw wrote: >>> >>> "if isinstance(x, (int,long))", which is parsed as "if PyInt_Check(x) or >>> PyLong_Check(x)" is slightly slower than "if PyInt_Check(x) || >>> PyLong_Check(x)". >> >> That is very surprisin

Re: [Cython] Supporting cython.operator in C

2016-06-02 Thread Jeroen Demeyer
On 2016-06-02 21:12, Robert Bradshaw wrote: "if isinstance(x, (int,long))", which is parsed as "if PyInt_Check(x) or PyLong_Check(x)" is slightly slower than "if PyInt_Check(x) || PyLong_Check(x)". That is very surprising. How much slower? With GCC 4.9.3, roughly 4% for a simple loop like fo

Re: [Cython] Supporting cython.operator in C

2016-06-02 Thread Robert Bradshaw
On Thu, Jun 2, 2016 at 12:57 AM, Jeroen Demeyer wrote: > On 2016-06-02 05:43, Robert Bradshaw wrote: >>> >>> 2. "x || y" because Cython's "x or y" generates complicated code which >>> isn't >>> optimized as well as "x || y". >> >> I just tried using gcc -O3 and the resulting assembly is identical.

Re: [Cython] Supporting cython.operator in C

2016-06-02 Thread Jeroen Demeyer
On 2016-06-02 05:43, Robert Bradshaw wrote: 2. "x || y" because Cython's "x or y" generates complicated code which isn't optimized as well as "x || y". I just tried using gcc -O3 and the resulting assembly is identical. Well, that would depend on what x and y are. A very concrete example: "

Re: [Cython] Supporting cython.operator in C

2016-06-02 Thread Jeroen Demeyer
On 2016-06-02 05:43, Robert Bradshaw wrote: You can always define your own macro #define ASSIGN(a, b) (a = b). That's basically my whole point. This ASSIGN should be called cython.operator.assign. ___ cython-devel mailing list cython-devel@python.or

Re: [Cython] Supporting cython.operator in C

2016-06-01 Thread Robert Bradshaw
On Wed, Jun 1, 2016 at 1:56 PM, Jeroen Demeyer wrote: > On 2016-05-31 20:35, Robert Bradshaw wrote: >> >> I can't think of any fundamental reason these couldn't be implemented >> in C, but there's really no need to do so as they can't be overridden >> in C. > > > Well, for the comma operator there

Re: [Cython] Supporting cython.operator in C

2016-06-01 Thread Jeroen Demeyer
On 2016-05-31 20:35, Robert Bradshaw wrote: I can't think of any fundamental reason these couldn't be implemented in C, but there's really no need to do so as they can't be overridden in C. Well, for the comma operator there might be no reason. However, it would be nice if one could generate a

Re: [Cython] Supporting cython.operator in C

2016-05-31 Thread Robert Bradshaw
I can't think of any fundamental reason these couldn't be implemented in C, but there's really no need to do so as they can't be overridden in C. On Tue, May 31, 2016 at 3:28 AM, Jeroen Demeyer wrote: > The following code > > cimport cython.operator > cdef long foo(long x, long y): > return c

[Cython] Supporting cython.operator in C

2016-05-31 Thread Jeroen Demeyer
The following code cimport cython.operator cdef long foo(long x, long y): return cython.operator.comma(x, y) gives AttributeError: 'CBinopNode' object has no attribute 'analyse_c_operation' Is there any fundamental reason why such operators are only implemented for C++ and not pure C? Wh