Re: Cython taking more time than regular Python

2016-09-21 Thread Gregory Ewing
Lawrence D’Oliveiro wrote: Don’t forget “functino”. :) ... is that the gauge boson for the function field? Or is that a “functon”? One of them might be spin-½ ... A functino would be the supersymmetric partner of a bosonic function. For a fermionic function, its partner would be a sfunction.

Re: Cython taking more time than regular Python

2016-09-21 Thread Lawrence D’Oliveiro
On Wednesday, September 21, 2016 at 6:05:07 PM UTC+12, Gregory Ewing wrote: > > Christian Gollwitzer wrote: > >> It may take a microsecond to call a functino from Python. > > Obviously the compiler used was a "dump" compiler. :-) Don’t forget “functino”. :) For some reason it awakens

Re: Cython taking more time than regular Python

2016-09-21 Thread Gregory Ewing
Christian Gollwitzer wrote: However, I'm not convinced it did succeed here. An evaluation of the Gauß formula would run in a few *nanoseconds* on any moddern machine. It may take a microsecond to call a functino from Python. a hundred microseconds means that the loop does run. Obviously the

Re: Cython taking more time than regular Python

2016-09-20 Thread Peter Otten
Christian Gollwitzer wrote: > Am 20.09.16 um 09:44 schrieb Peter Otten: >> Stefan Behnel wrote: >> >>> Peter Otten schrieb am 19.09.2016 um 14:55: In [7]: %%cython def omega(int n): cdef long i cdef long result = 0 for i in range(n): result += i

Re: Cython taking more time than regular Python

2016-09-20 Thread Christian Gollwitzer
Am 20.09.16 um 09:44 schrieb Peter Otten: Stefan Behnel wrote: Peter Otten schrieb am 19.09.2016 um 14:55: In [7]: %%cython def omega(int n): cdef long i cdef long result = 0 for i in range(n): result += i return result ...: In [8]: %timeit omega(10) 1 loops, best

Re: Cython taking more time than regular Python

2016-09-20 Thread BartC
On 20/09/2016 06:27, Stefan Behnel wrote: Peter Otten schrieb am 19.09.2016 um 14:55: In [7]: %%cython def omega(int n): cdef long i cdef long result = 0 for i in range(n): result += i return result ...: In [8]: %timeit omega(10) 1 loops, best of 3: 91.6 µs per loop

Re: Cython taking more time than regular Python

2016-09-20 Thread Peter Otten
Stefan Behnel wrote: > Peter Otten schrieb am 19.09.2016 um 14:55: >> In [7]: %%cython >> def omega(int n): >> cdef long i >> cdef long result = 0 >> for i in range(n): result += i >> return result >>...: >> >> In [8]: %timeit omega(10) >> 1 loops, best of 3: 91.6 µs

Re: Cython taking more time than regular Python

2016-09-19 Thread Arshpreet Singh
On Tuesday, 20 September 2016 11:00:40 UTC+5:30, Stefan Behnel wrote: > > In [8]: %timeit omega(10) > > 1 loops, best of 3: 91.6 µs per loop > > Note that this is the worst benchmark ever. Any non-dump C compiler will > happily apply Young Gauß and calculate the result in constant

Re: Cython taking more time than regular Python

2016-09-19 Thread Stefan Behnel
Peter Otten schrieb am 19.09.2016 um 14:55: > In [7]: %%cython > def omega(int n): > cdef long i > cdef long result = 0 > for i in range(n): result += i > return result >...: > > In [8]: %timeit omega(10) > 1 loops, best of 3: 91.6 µs per loop Note that this is the

Re: Cython taking more time than regular Python

2016-09-19 Thread Peter Otten
Arshpreet Singh wrote: > Hope this is good place to ask question about Cython as well. > Following code of mine is taking 2.5 times more time than Native Python > code: > > %%cython > import numpy as np > a = np.array([]) > def large_sum2(int num_range): > np.append(a,[i for i in

Cython taking more time than regular Python

2016-09-19 Thread Arshpreet Singh
Hope this is good place to ask question about Cython as well. Following code of mine is taking 2.5 times more time than Native Python code: %%cython import numpy as np a = np.array([]) def large_sum2(int num_range): np.append(a,[i for i in xrange(num_range)]) return a.sum %timeit