龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > python编程 >

深入理解Python 代码优化详解(6)

时间:2014-10-28 02:27来源:网络整理 作者:网络 点击:
分享到:
复制代码 代码如下: [root@v5254085f259 cpython]# wget -N http://cython.org/release/Cython-0.15.1.zip --2012-04-16 22:08:35-- http://cython.org/release/Cython-0.15.1.zip Resolving cython.org...

复制代码 代码如下:

[root@v5254085f259 cpython]# wget -N http://cython.org/release/Cython-0.15.1.zip
 --2012-04-16 22:08:35--  http://cython.org/release/Cython-0.15.1.zip
 Resolving cython.org... 128.208.160.197
 Connecting to cython.org|128.208.160.197|:80... connected.
 HTTP request sent, awaiting response... 200 OK
 Length: 2200299 (2.1M) [application/zip]
 Saving to: `Cython-0.15.1.zip'
 100%[======================================>] 2,200,299   1.96M/s   in 1.1s
 2012-04-16 22:08:37 (1.96 MB/s) - `Cython-0.15.1.zip' saved [2200299/2200299]

  第二步:解压

复制代码 代码如下:

[root@v5254085f259 cpython]# unzip -o Cython-0.15.1.zip

  第三步:安装

复制代码 代码如下:

python setup.py install

  安装完成后直接输入 cython,如果出现如下内容则表明安装成功。

复制代码 代码如下:

[root@v5254085f259 Cython-0.15.1]# cython
 Cython (http://cython.org) is a compiler for code written in the
 Cython language.  Cython is based on Pyrex by Greg Ewing.
 Usage: cython [options] sourcefile.{pyx,py} ...
 Options:
  -V, --version                  Display version number of cython compiler
  -l, --create-listing           Write error messages to a listing file
  -I, --include-dir <directory>  Search for include files in named directory
                                 (multiple include directories are allowed).
  -o, --output-file <filename>   Specify name of generated C file
  -t, --timestamps               Only compile newer source files
  -f, --force                    Compile all source files (overrides implied -t)
  -q, --quiet                    Don't print module names in recursive mode
  -v, --verbose                  Be verbose, print file names on multiple compil ation
  -p, --embed-positions          If specified, the positions in Cython files of each
  function definition is embedded in its docstring.
  --cleanup <level>
  Release interned objects on python exit, for memory debugging.
    Level indicates aggressiveness, default 0 releases nothing.
  -w, --working <directory>
  Sets the working directory for Cython (the directory modules are searched from)
  --gdb Output debug information for cygdb
  -D, --no-docstrings
              Strip docstrings from the compiled module.
  -a, --annotate
              Produce a colorized HTML version of the source.
  --line-directives
              Produce #line directives pointing to the .pyx source
  --cplus
              Output a C++ rather than C file.
  --embed[=<method_name>]
              Generate a main() function that embeds the Python interpreter.
  -2          Compile based on Python-2 syntax and code seman tics.
  -3          Compile based on Python-3 syntax and code seman tics.
  --fast-fail     Abort the compilation on the first error
  --warning-error, -Werror       Make all warnings into errors
  --warning-extra, -Wextra       Enable extra warnings
  -X, --directive <name>=<value>
  [,<name=value,...] Overrides a compiler directive

精彩图集

赞助商链接