[Python-Dev] Thoughts on -O (original) (raw)

Delaney, Timothy C (Timothy) tdelaney@avaya.com
Tue, 29 Apr 2003 10:10:39 +1000


Was doing some thinking in the shower this morning, and came up with = some ideas for specifying optimisation. These are currently quite = nebulous thoughts ...

We have the current situation:

-O only removes asserts -OO removes asserts and docstrings.

I think this is an ideal time to revisit the purpose of -O for 2.4 or = later.

IMO the "vanilla" mode should be a "release" mode. Users should not have = to use a command-line option to gain "release" optimisations such as = asserts.

I would propose that we have the following modes for python to work in.

  1. Release/Production mode (no command-line switch)
  1. Optimised mode (-O)
  1. Docstring elimination mode (-OO)
  1. Debug mode (-D?)

I would see Debug mode being used by developers in unit tests, code = coverage, etc.

.pyc and .pyo files would need to know which optimisations they were = compiled with so that if they would be loaded again with the "wrong" = optimisations they would be re-compiled.

Anyway, any thoughts, rebuttals, etc would be of interest. I'd like to = get some discussion before I create a PEP.

Cheers.

Tim Delaney