Re: [Cython] Conditional import in pure Python mode

2012-05-01 Thread Robert Bradshaw
On Tue, May 1, 2012 at 1:02 PM, Stefan Behnel wrote: > Francesc Alted, 01.05.2012 21:49: >> On 5/1/12 2:39 PM, mark florisson wrote: >>> On 1 May 2012 20:22, Stefan Behnel wrote: Stefan Behnel, 01.05.2012 21:14: > 2) Use math.pxd as an override for the math module. I'm not sure yet how >>

Re: [Cython] Conditional import in pure Python mode

2012-05-01 Thread Stefan Behnel
Francesc Alted, 01.05.2012 21:49: > On 5/1/12 2:39 PM, mark florisson wrote: >> On 1 May 2012 20:22, Stefan Behnel wrote: >>> Stefan Behnel, 01.05.2012 21:14: 2) Use math.pxd as an override for the math module. I'm not sure yet how that would best be made to work, but it shouldn't be all

Re: [Cython] Conditional import in pure Python mode

2012-05-01 Thread Stefan Behnel
mark florisson, 01.05.2012 21:39: > On 1 May 2012 20:22, Stefan Behnel wrote: >> Stefan Behnel, 01.05.2012 21:14: >>> 2) Use math.pxd as an override for the math module. I'm not sure yet how >>> that would best be made to work, but it shouldn't be all that complex. It >>> already works (mostly?) fo

Re: [Cython] Conditional import in pure Python mode

2012-05-01 Thread Francesc Alted
On 5/1/12 2:39 PM, mark florisson wrote: On 1 May 2012 20:22, Stefan Behnel wrote: Stefan Behnel, 01.05.2012 21:14: 2) Use math.pxd as an override for the math module. I'm not sure yet how that would best be made to work, but it shouldn't be all that complex. It already works (mostly?) for num

Re: [Cython] Conditional import in pure Python mode

2012-05-01 Thread mark florisson
On 1 May 2012 20:22, Stefan Behnel wrote: > Stefan Behnel, 01.05.2012 21:14: >> 2) Use math.pxd as an override for the math module. I'm not sure yet how >> that would best be made to work, but it shouldn't be all that complex. It >> already works (mostly?) for numpy.pxd, for example, although that

Re: [Cython] Conditional import in pure Python mode

2012-05-01 Thread Stefan Behnel
Stefan Behnel, 01.05.2012 21:14: > 2) Use math.pxd as an override for the math module. I'm not sure yet how > that would best be made to work, but it shouldn't be all that complex. It > already works (mostly?) for numpy.pxd, for example, although that's done > explicitly in user code. BTW, I think

Re: [Cython] [cython-users] Conditional import in pure Python mode

2012-05-01 Thread Stefan Behnel
Ian Bell, 01.05.2012 15:50: > On Tue, May 1, 2012 at 9:21 PM, Stefan Behnel wrote: > On 29 April 2012 01:33, Ian Bell wrote: >> idiom like >> >> if cython.compiled: >> cython.import('from libc.math cimport sin') >> else: >> from math import sin >> >> Actually, in

Re: [Cython] [cython-users] Conditional import in pure Python mode

2012-05-01 Thread Stefan Behnel
>>> On 29 April 2012 01:33, Ian Bell wrote: idiom like if cython.compiled: cython.import('from libc.math cimport sin') else: from math import sin Actually, in this particular case, I would even accept a solution that special cases the "math" module internally

Re: [Cython] Wacky idea: proper macros

2012-05-01 Thread Dag Sverre Seljebotn
On 05/01/2012 10:29 AM, Dag Sverre Seljebotn wrote: On 04/30/2012 11:36 PM, William Stein wrote: On Mon, Apr 30, 2012 at 2:32 PM, Dag Sverre Seljebotn wrote: Wes McKinney wrote: On Mon, Apr 30, 2012 at 4:55 PM, Nathaniel Smith wrote: On Mon, Apr 30, 2012 at 9:49 PM, Dag Sverre Seljebotn

Re: [Cython] Wacky idea: proper macros

2012-05-01 Thread Dag Sverre Seljebotn
On 04/30/2012 11:36 PM, William Stein wrote: On Mon, Apr 30, 2012 at 2:32 PM, Dag Sverre Seljebotn wrote: Wes McKinney wrote: On Mon, Apr 30, 2012 at 4:55 PM, Nathaniel Smith wrote: On Mon, Apr 30, 2012 at 9:49 PM, Dag Sverre Seljebotn wrote: JIT is really the way to go. It is one th

Re: [Cython] Code generated for the expression int(x)+1

2012-05-01 Thread Stefan Behnel
Ask F. Jakobsen, 01.05.2012 09:53: > I am having a simple performance problem that can be resolved by splitting up > an expression in two lines. I don't know if it is a bug or I am missing > something. > > The piece of code below is translated to slow code > > 1) > cdef int i > i=int(x)

[Cython] Code generated for the expression int(x)+1

2012-05-01 Thread Ask F. Jakobsen
Hi all, I am having a simple performance problem that can be resolved by splitting up an expression in two lines. I don't know if it is a bug or I am missing something. The piece of code below is translated to slow code 1) cdef int i i=int(x)+1 whereas the code below is translated to