The first step is to generate the Pyx file
For example, generate a function
#-*-Coding:utf8-*-
Import datetime
Import Random
Import NumPy as NP
Import Talib as Ta
Import Math
Import CSV
def Judge (Closearray,iskfinisharray):
IsTrue = ("true" = = str (iskfinisharray[0]). Lower ())
result = ["Nothing", Closearray[0]]
listclose=[0,1,2,3]
if isTrue = = True:
Np.array (Listclose)
Close = Closearray[0]
result = ["Judge", close]
return result
The second step generates setup.py
From Distutils.core Import Setup
From distutils.extension Import extension
From cython.distutils import Build_ext
Ext_modules = [Extension ("Strategytestcython", ["Strategytestcython.pyx"])]
Setup
Name = "Strategytestcython Pyx",
Cmdclass = {' Build_ext ': Build_ext},
Ext_modules = Ext_modules
)
Step three run Python setup.py build_ext--inplace
Compiling the Xxx.pyd
Step fourth run the compiled file
#!/usr/bin/python
# Coding=utf-8
Import Strategytestcython
Print Strategytestcython.judge ([1326],["True"])
Results
[' Judge ', 1326]
Facilitates Cython to complete the encryption of Python core source code