Reputation: 4500
I have a basic string manip
function in ```python``
def str_process(string_list):
op = []
for each_str in string_list:
op.append(each_str+"_random token")
return op
which works fine. But when I try to run the same function in cython:
import cython
cdef list func(list string_list):
cdef list op =[]
cdef str each_str
for each_str in string_list:
op.append(each_str+"_random token")
return op
I put the above cython function
in test.pyx
file and call it using the following
from distutils.core import setup
from Cython.Build import cythonize
setup(ext_modules=cythonize('test.pyx'))
Error:
option -f not recognized
I am brand new to cython and any suggestions on the mistake will be great.
Upvotes: 2
Views: 1313
Reputation: 568
I was able to successfully cythonize your code with the command python3 setup.py build_ext --inplace
. It looks like you were simply running your setup.py file incorrectly.
Also, unless you have more code that you aren't showing in this example, you do not need to import cython in your .pyx file.
Upvotes: 2