I have a foo.py file and it contains a very slow function that takes 8 minutes to calculate. However, when I change the file to foo.pyxand compile it with cython without any changes, it takes 5 minutes to calculate.
My question is: if I run cython foo.pyinstead cython foo.pyx, then run
gcc -shared -pthread -fPIC -fwrapv -O2 -Wall -fno-strict-aliasing -I/usr/include/python2.7 -o foo.so foo.c
When I run import foo, will python import the file .pyor compiled file .so? Does pyx really have to be there, and is there a way to get it to take .soover .pyif it exists?
The reason for this is that I cannot change the name foo.py without breaking code on other people's computers, but I would really like it to be faster for my tests. It would be great if I could just compile it locally without worrying about breaking the code elsewhere.
(I test this when we talk, but its from time to time)
source
share