美文网首页
Cython 简明手册

Cython 简明手册

作者: MrHamster | 来源:发表于2017-09-26 23:01 被阅读363次
  • 什么是Cython

cython 是python的超集
简单的说:python + c

  • 安装

     pip install Cython -U
    

    一次性安装

    pip install Cython -U--install-option="--no-cython-compile"
    
  • helloworld

    1. file: helloworld.pyx
      def hello_world(name="World"):
            print("Hello %s!" % name)
      
    2. file: setup.py
      from distutils.core import setup
      from Cython.Build import cythonize
      
      setup(
        name = 'Hello world app',
        ext_modules = cythonize("helloworld.pyx"),
        )
      
         3. build
             ```language-bash
             python setup.py build_ext --inplace
             ```
      
             在当前目录下生成```helloworld.so``` (mac/linux, pyd windows)
      
         4. file: main.py
             ```language-python
             from helloworld import hello_world
             hello_world() # out: Hello World
             ```
      
  • How

    • cython 是python的超集,可以被看成是python + c
    • install
      • 安装
      pip install Cython -U
      
      • 一次性安装
      pip install Cython -U--install-option="--no-cython-compile"
      
      • helloworld
        1. file: helloworld.pyx

          def hello_world(name="World"):
              print("Hello %s!" % name)
          
        2. file: setup.py

          from distutils.core import setup
          from Cython.Build import cythonize
          
          setup(
              name = 'Hello world app',
              ext_modules = cythonize("helloworld.pyx"),
          )
          
        3. build

          python setup.py build_ext --inplace
          

          在当前目录下生成helloworld.so (mac/linux, pyd windows)

        4. file: main.py

          from helloworld import hello_world
          hello_world() # out: Hello World
          

相关文章

  • Cython 简明手册

    什么是Cython cython 是python的超集简单的说:python + c 安装 pip install...

  • Org-mode 简明手册

    Org-mode 简明手册

  • Linux 常用命令总结

    linux 命令速查手册linux 常用操作命令 sed 简明教程 awk 简明教程 常用命令 ls ...

  • InfluxDB简明手册 初稿完成了!

    InfluxDB简明手册 操作教程 中文文档。 手册不断完善中,欢迎 pull request! 如果对你有所...

  • Cmd Markdown 简明语法手册

    Cmd Markdown 简明语法手册 标签: MarkdownEditor Cmd-Markdown 1. 斜体...

  • Excel简明手册

    从Excel 的基本处理 和函数进阶角度讲述 excel的使用方法. 基本设置与数据 快速访问栏 清除 格式刷 自...

  • Markdown简明手册

    #效率工具 #有道云笔记说明及使用:    这篇介绍是基于有道云笔记的markdown版本整理的一个比较全面的...

  • Markdown 简明手册

    标题 引用块 列表 无序列表 有序列表 水平线 下面每一行都会得到一个水平线 链接 强调 图片 行内图片 引用图片...

  • 简明语法手册

    1. 斜体和粗体 使用 * 和 ** 表示斜体和粗体。 示例: 这是 斜体,这是 粗体。 2. 分级标题 使用 =...

  • php简明手册

    # **PHP简明手册** ## **变量 和 常量** > 1. 变量和常量是PHP中最基本的数据存储单元,它们...

网友评论

      本文标题:Cython 简明手册

      本文链接:https://www.haomeiwen.com/subject/uikxextx.html