Re: [Cython] ctypes Vs Cython

2009-05-13 Thread Robert Bradshaw
On May 13, 2009, at 12:57 PM, Chris Colbert wrote: > so my intitial guess that the problem was with my inability to > properly build a dll was correct. > > After reading (partially) the gcc manual on compiling optimizations > i get the following result: > > Starting Threads > >>> no GIL cython

Re: [Cython] ctypes Vs Cython

2009-05-13 Thread Chris Colbert
so my intitial guess that the problem was with my inability to properly build a dll was correct. After reading (partially) the gcc manual on compiling optimizations i get the following result: Starting Threads >>> no GIL cython: Value: 1999000.00 Time: 8.076570 s no GIL ctypes: Value: 19990

Re: [Cython] ctypes Vs Cython

2009-05-13 Thread Chris Colbert
I ran another benchmark showing the opposite case: a single call to a long running c function. The results are surprising, Cython is much much faster. (this may be do my inability to compile an optimized dll). Anyway, the following is the code I tested: # Cython script (.pyx) # cdef

Re: [Cython] ctypes Vs Cython

2009-05-13 Thread Robert Bradshaw
On May 13, 2009, at 1:50 AM, Sebastien Binet wrote: > On Wednesday 13 May 2009 10:41:43 Robert Bradshaw wrote: >> On May 13, 2009, at 1:17 AM, Sebastien Binet wrote: >>> hi, >>> >>> On Wednesday 13 May 2009 08:35:27 Robert Bradshaw wrote: On May 12, 2009, at 9:47 PM, Mohamed Lrhazi wrote: >>>

Re: [Cython] ctypes Vs Cython

2009-05-13 Thread Robert Bradshaw
On May 13, 2009, at 1:17 AM, Sebastien Binet wrote: > hi, > > On Wednesday 13 May 2009 08:35:27 Robert Bradshaw wrote: >> On May 12, 2009, at 9:47 PM, Mohamed Lrhazi wrote: >>> On Wed, May 13, 2009 at 12:31 AM, Chris Colbert >>> >>> wrote: If your making lots of rapid calls to short running

Re: [Cython] ctypes Vs Cython

2009-05-13 Thread David Cournapeau
On Wed, May 13, 2009 at 1:31 PM, Chris Colbert wrote: > What follows is my 0.02, and i'm really new at these two libs so keep in > mind I could be completely off base. I'm sure someone will jump in and > correct my errors. > > I think the speed is really going to depend on the nature of your calls

Re: [Cython] ctypes Vs Cython

2009-05-13 Thread Dag Sverre Seljebotn
Sebastian Pinet wrote: > how would this translate into the pure-python mode ? (I couldn't seem to > be > able to declare the C-sqrt function using the pure-python mode of cython: > http://wiki.cython.org/pure wasn't helpful) You can't. Calling C functions directly is a fundamental consequence of c

Re: [Cython] ctypes Vs Cython

2009-05-13 Thread Sebastien Binet
hi, On Wednesday 13 May 2009 08:35:27 Robert Bradshaw wrote: > On May 12, 2009, at 9:47 PM, Mohamed Lrhazi wrote: > > On Wed, May 13, 2009 at 12:31 AM, Chris Colbert > > > > wrote: > >> If your making lots of rapid calls to short running functions in the > >> C-library, then you may start to feel

Re: [Cython] ctypes Vs Cython

2009-05-12 Thread Robert Bradshaw
On May 12, 2009, at 9:47 PM, Mohamed Lrhazi wrote: > On Wed, May 13, 2009 at 12:31 AM, Chris Colbert > wrote: >> If your making lots of rapid calls to short running functions in the >> C-library, then you may start to feel the ctypes overhead. > > That's what I was afraid to hear.. Hopefully a

Re: [Cython] ctypes Vs Cython

2009-05-12 Thread Mohamed Lrhazi
On Wed, May 13, 2009 at 12:31 AM, Chris Colbert wrote: > If your making lots of rapid calls to short running functions in the > C-library, then you may start to feel the ctypes overhead. That's what I was afraid to hear.. What I was hoping to hear is "Oh no, ctypes is all C anyways, and will perf

Re: [Cython] ctypes Vs Cython

2009-05-12 Thread Chris Colbert
I should also state, that its a helluva lot easier to get something up and running using cython vs ctypes. So if your not doing application programming intented for distribution, my vote goes to Cython. I can write my whole script and have it execute to completion using Cython, before i'm even don

Re: [Cython] ctypes Vs Cython

2009-05-12 Thread Chris Colbert
What follows is my 0.02, and i'm really new at these two libs so keep in mind I could be completely off base. I'm sure someone will jump in and correct my errors. I think the speed is really going to depend on the nature of your calls into the c library. From the code i've examined, there will pro

[Cython] ctypes Vs Cython

2009-05-12 Thread Mohamed Lrhazi
Hello, How fast/slow is using ctypes to talk to a C lib, compared to doing it directly form Cython? While debugging an issue using ctypes, I found myself writing code that was mixing the two methods... the Cython module was passing a pointer to my Python code, which then uses ctypes functions to