-
-
Notifications
You must be signed in to change notification settings - Fork 30.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve -O docs #61434
Comments
This is what the current documentation says: -O -OO As far as I know, the only "optimization" that's done is removal of __debug__ sections and assert statements and has been like this for years. Maybe it should say so "-O does not do any optimizations, only removes assert statement" or so. |
It should also add that in the future, more optimizations may be added i.e. a peephole optimizer, etc. |
There were not for at least 10 years. I would also be the first one to strongly object adding optimizations only under -O, because that already changes semantics. |
Ramchandra, as it turns out, if we deem an optimization semantically safe, we do it without -O, it we deem it unsafe, we don't do it at all. Thus, the real effect is to remove assert statements and optimise code as if "__debug__" was replaced by a literal zero (effectively). So a more meaningful description would be: -O |
I agree that we should document exactly what is now. Patch replaces first sentence with Nick's. It is against 3.4, but should be identical for all versions. Maciej, thanks for reminding us to finally fix this. |
Should probably be "Remove", not "Removes" (we use infinitives to describe the actions undertaken by a command / option / method ...). |
Perhaps '__debug__' need markup, but if so, I don't know how. |
+1 for Remove instead of Removes For the online docs, :const:`__debug__` should work (resolving to http://docs.python.org/3/library/constants.html#__debug__, which is currently described using some slightly brain-bending phrasing) We should also tweak the output of "python -h" (the help string is in ./Modules/main.c) |
+1, I've been bothered by this description of "optimization" for a long time. Terry's patch LGTM |
Also IMO -OO should stop talking about optimizations. Maybe "Do what -O does and discard docstrings"? |
I added :const: and tweaked -OO entry and -h startup display. |
There's a typo in your patch: +-O : remove assert and __debug__-dependent statements; change .py\n\ should say ".pyc", not ".py". |
Also, in 3.2 and higher I'm not sure there's a point in mentioning pyc/pyo files; they're all shelved in __pycache__ now. |
I corrected my copy of the .diff. Since this issue is so far focused on removing the false optimize claim, hiding .pyx info is a new sub-issue. I will follow whatever the consensus is, but since this is a cpython-specific doc and help, I would prefer to give complete info. In fact, I would like to add 'stored in __pycache__' or even 'hidden away in __pycache__', the latter to suggest that most people should generally forget about them. On Windows, _xxx files like __pycache__ appear in both Command Prompt dir and Explorer file listings, so beginners need to known that __cache__ is both normal and ignorable. |
On Tue, Mar 12, 2013 at 1:18 PM, Antoine Pitrou <report@bugs.python.org> wrote:
It still makes a difference for bytecode-only files, which aren't in __pycache__ Cheers, |
I left a review on rietveld. |
Terry, do you want to update your patch? |
Should I make a pull request for Terry's last patch? |
Cheryl: yes, with changes in responses to Ezio's review. Nick or Antoine: has there been any change to meaning of -O or -OO that I am not remembering? |
We don't change the extension on optimised pyc files any more, we add an optimisation marker to the name without changing the file extension: https://www.python.org/dev/peps/pep-0488/ (This means |
I've made a PR and tried to integrate the changes from PEP-488. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: