如何 运行 Jython 与 __debug__ False

How to run Jython with __debug__ False

这似乎是一个愚蠢的问题,但我对此感到困惑。

Jython 2.7.0 "final release",平台 W7

我只想 运行 我的应用程序,以便 __debug__ 为 False 并跳过 assert 语句。

我试着去 jython -O my_app.py 它说

Unknown option: O

...做了一些谷歌搜索但无济于事...

任何寻求答案的人

https://www.safaribooksonline.com/library/view/jython-essentials/9781449397364/apds02.html

Major Design Differences

Debug and optimization

Jython does not currently recognize the CPython command-line switch -O, which removes assert statements and other debug information. In Jython, the __debug__ global value, which controls this behavior, is always set to 1 and is not writable.

...所以(目前)您必须实现自己的(可关闭)断言式机制。可能有点问题,因为即使有一个布尔值 "is_production_run" 也需要时间来评估,尽管据我所知这可能只是一条机器指令。

不知道Jython 高层有没有计划实现这一功能呢?没想到会这么复杂...