Sturla Molden wrote:
> Chris Colbert skrev:
>> so moral of the story, if you have a numpy script that makes repeated
>> use of pow you probably wont speed it up with cython, because pow is a
>> huge bottleneck.
>>   
> I'd go further than this:
> 
> NumPy is written in C and you should not expect replacing NumPy's C with 
> Cython's generated C to give you a huge performance boost. In some 
> situations NumPy will call high performance libraries such as MKL or 
> ATLAS, and chances that you can write something more efficient are slim. 
> There are really only two (or maybe three) situations where Cython will 
> help over vectorized NumPy:
> 
> - The first is creation of temporary arrays from overloaded operators. 
> If this is the bottleneck, Cython might help. Computation is fast, 
> memory access is slow.
> 
> - The second is algorithms that are iterative or recursive, but not 
> "data parallel":
> 
>     for i in range(n):
>         x[n] = foobar(x[n-1])
> 
> - The third is NumPy not releasing the GIL, and restricting 
> multithreaded code to one CPU.

Out of curiosity, does it happen often that NumPy does not release the 
GIL? Because of necessity or because it's just not been implemented?

-- 
Dag Sverre
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to