Cython -a标志(生成黄色阴影的HTML),不带命令行 [英] Cython -a flag (to generate yellow-shaded HTML) without command line

查看:240
本文介绍了Cython -a标志(生成黄色阴影的HTML),不带命令行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从命令行运行时

$ cython -a mycode.pyx

您将获得一个非常漂亮的带有黄色阴影的HTML注释文件,以指示慢速python操作与快速的C操作。每次在Sage中编译Cython代码时,您还将获得与链接相同的HTML文件。我的问题是:(1)如果我使用distutils进行编译,是否可以获取此HTML文件? (2)如果我使用pyximport进行编译,可以获取此HTML文件吗?谢谢!!

you get a really nice HTML "annotation" file with yellow shading to indicate slow python operations vs fast C operations. You also get this same HTML file as a link every time you compile Cython code in Sage. My questions are: (1) Can I get this HTML file if I'm compiling using distutils? (2) Can I get this HTML file if I'm compiling using pyximport? Thanks!!

推荐答案

感谢larsmans的评论以及 Cython电子邮件列表,我现在有很多令人满意的选项可以在不离开IPython的情况下生成注释 HTML文件:

Thanks to larsmans's comment and the Cython email list, I now have many satisfying options to generate the "annotate" HTML file without leaving IPython:

(1)使用子流程...

(1) Use subprocess...

import subprocess
subprocess.call(["cython","-a","myfilename.pyx"])

(2)打开全局注释标志在自己的Cython中,编译之前:

(2) Turn on the global annotate flag in Cython myself, before compiling:

import Cython.Compiler.Options
Cython.Compiler.Options.annotate = True

(3)将 annotate = True 传递到 cythonize() [使用 distutils 编译方法]。

(3) Pass annotate=True into cythonize() [when using the distutils compilation method].

似乎pyximport并没有自己的直接选择在注释上。

It seems that pyximport does not have its own direct option for turning on annotation.

这篇关于Cython -a标志(生成黄色阴影的HTML),不带命令行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆