On Tue, Oct 20, 2020 at 05:30:54PM +0300, Serhiy Storchaka wrote: > I do not want to create tens of alternate PEPs with minor variations, > and this issue is not worth a PEP. What is your opinion about this? Is > it worth to include such optimization? For what kind of variables should > it be applied? Should it include global '_'? Should it be merely an > optimization (maybe controlled by the -O option) or change in the language?
Assuming that this actually has a benefit, in either speed or memory, how about this? 1. Only eliminate local variables, never globals. 2. By default, only variables with a leading underscore are eliminated. This will(?) avoid breaking tests for the debugger etc. that you mentioned. 3. Under -O, allow more aggressive optimization that eliminates non-underscore variables too. 4. This is an implementation feature, not a language promise. Other interpreters do not have to follow. 5. To be clear, variables are only eliminated if they are assigned to, but never written to: def func(): _a = 1 # not eliminated _b = 2 # eliminated return _a -- Steve _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/DBQIS63WTM4PFAQRDJ6QVUYHN4ZPUDF4/ Code of Conduct: http://python.org/psf/codeofconduct/