禁用Python基本优化(-O) [英] Disable Python basic optimization (-O)

查看:57
本文介绍了禁用Python基本优化(-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 to False
  • 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屋!

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