cython does not work - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: cython does not work (/thread-14805.html) |
cython does not work - skorost5 - Dec-18-2018 cannot display Hello on cython file: set.py from distutils.core import setup from Cython.Build import cythonize import temp compiler_directives = { 'language_level': 2, 'optimize.use_switch': True, 'profile': True, } setup( packages=["XXXXXX"], ext_modules=cythonize("temp.pyx", # module_list="temp.pxd", #pyx #compiler_directives=compiler_directives, ) )file temp.pyx cdef class Temp1: cdef void as(self): print("Hello") Temp1.as() RE: cython does not work - Gribouillis - Dec-18-2018 as is a keyword in python. This may be the cause of the error. Can't you rename the method?
RE: cython does not work - skorost5 - Dec-18-2018 fixed as on pprr file: set.py from distutils.core import setup from Cython.Build import cythonize import temp print("y") compiler_directives = { 'language_level': 2, 'optimize.use_switch': True, 'profile': True, } setup( packages=["XXXXXX"], ext_modules=cythonize("temp.pyx", # module_list="temp.pxd", #pyx #compiler_directives=compiler_directives, ) )file temp.pyx from time import * #cimport ctemp cdef class Temp1: cdef void pprr(self): print("rr") cdef Temp1 p1 p1=Temp1() p1.pprr() print("Hello World")after starting set.py the program outputs the following--------------------------------------------------------------- It is not clear why does not display print("rr") --------------------------------------------------------
RE: cython does not work - Gribouillis - Dec-18-2018 Normally you don't import the module in 'setup.py'. Removing the 'import temp', here is my output in a linux terminal
RE: cython does not work - skorost5 - Dec-18-2018 this command starts python temp.pyx build_ext --inplace starting from the console results in the following
RE: cython does not work - skorost5 - Dec-19-2018 once no more answers, I will try to make himself |