禁用Python基本优化(-O) [英] Disable Python basic optimization (-O)
问题描述
在给定的嵌入式Linux计算机上,我安装了Python 3.3发行版,该发行版似乎默认启用了优化选项 -O
.这具有以下效果:
- 正在生成
-
.pyo
文件(而不是.pyc
) -
断言
语句无效 -
__ debug __
设置为False
- 某些IDE似乎无法提供远程调试(请参见 WingIDE )
有没有办法在命令行上禁用基本优化?我试图将 PYTHONOPTIMIZE
设置为空字符串,但这没有任何效果.
我使用的Python发行版随附Yocto,并且默认情况下在其中激活了基本优化功能( Py_OptimizeFlag
硬编码为1
而不是 0
).
该版本的Python还带有一个额外的 -N
标志(在普通的Python发行版中没有记录).
所以我的问题的答案是设置 -N
命令行选项,或者对Yocto随附的Python源应用补丁并将其重新编译(如Karoly Horvath所建议)./p>
On a given embedded Linux machine I have a Python 3.3 distribution installed which seems to have the optimization option -O
enabled by default.
This has the following effects:
.pyo
files are being generated (rather than.pyc
)assert
statements have no effect__debug__
is set toFalse
- Some IDEs seem to be unable to provide remote debugging (see WingIDE)
Is there a way to disable basic optimization on the command line? I tried to set PYTHONOPTIMIZE
to empty string but this does not have any effect.
The Python distribution I was using comes with Yocto and basic optimization is activated there by default (Py_OptimizeFlag
is hard coded to 1
rather than 0
).
That version of Python also comes with an extra -N
flag (which is not documented in the usual Python distributions).
So the answer to my question is to either set the -N
command line option or to apply a patch to the Python sources which come with Yocto and recompile (as suggested by Karoly Horvath).
这篇关于禁用Python基本优化(-O)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!