标签:coding tcl not build rom extension set 第一步 imp
第一步 生成pyx文件
例如生成函数
# -*- 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
第二步 生成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
)
第三步 运行 python setup.py build_ext --inplace
编译出XXX.pyd
第四步 运行编译文件
#!/usr/bin/python
# coding=utf-8
import StrategyTestCython
print StrategyTestCython.Judge([1326],["True"])
结果
[‘Judge‘, 1326]
标签:coding tcl not build rom extension set 第一步 imp
原文地址:http://www.cnblogs.com/fljie/p/7942772.html