View Single Post
  #1   (View Single Post)  
Old 26th August 2008
kasse kasse is offline
Fdisk Soldier
Join Date: Jun 2008
Posts: 67
Default How to vectorize a function for numpy arrays in Python

In python say that I have a numpy array
 myarray =array([item1,item2,...itemN])
all items are of the same type and I have a function
and I want to use myfun on myarray. I dont want to write a function that uses a for loop applying myfun on the elements in myarray since the for loops are so slow in python on big array 10^N elements. The predefined types and basic operations on these seem to work in vectorized format, so how do I write my own.
I know there is something called ufunc with numpy but I cannot access since the site appears to be down now. Vectorize and frompyfunc works but it is much slower that if you can make your own ufunc like.

Last edited by kasse; 26th August 2008 at 02:38 PM.
Reply With Quote