Cython 简化工具 Runcython

码农软件 · 软件分类 · 常用工具包 · 2019-08-16 05:58:26

软件介绍

Runcython 旨在简化 Cython 的使用过程,而不会牺牲掉可扩展性。在任何 Python 程序中使用 cython,main.py,只需要做

$ mv main.py main.pyx && runcython main.pyx

在标准的 cython 的构建程序里,运行 myprogram.py(x) 需要创建 myprogram.c,setup.py,myprogram.so 和 finally_user.py。流行的 pyximport 工具将这五个工具减少为两个,但这只是用于创建简单的构建。Runcython 走完了最后一步,只需要一个文件。它也可以用来处理复杂的构建方式,适用于任何 C/C++ 黑客。

示例代码:

# primes.pyx
def primes(int kmax):
    cdef int n, k, i
    cdef int p[1000000]
    result = []
    if kmax > 1000000:
        kmax = 1000000
    k = 0
    n = 2
    while k < kmax:
        i = 0
        while i < k and n % p[i] != 0:
            i = i + 1
        if i == k:
            p[k] = n
            k = k + 1
            result.append(n)
        n = n + 1
    return result

def main():
    print primes(5)


本文地址:https://codercto.com/soft/d/12460.html

Pragmatic Thinking and Learning

Pragmatic Thinking and Learning

Andy Hunt / The Pragmatic Bookshelf / 2008 / USD 34.95

In this title: together we'll journey together through bits of cognitive and neuroscience, learning and behavioral theory; you'll discover some surprising aspects of how our brains work; and, see how ......一起来看看 《Pragmatic Thinking and Learning》 这本书的介绍吧!

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具