I guess that you're talking about
https://github.com/python/cpython/pull/29810/files

To be honest, I never looked into Python/ast_opt.c. I expected a
shorter implementation, a copy/paste or a few lines additions of "x ==
y" optimization. But it seems like "1 == 1" is not optimized neither.
Oh. I made the assumptions that other operations were already
optimized.

Victor

On Mon, Nov 29, 2021 at 6:11 PM Serhiy Storchaka <storch...@gmail.com> wrote:
>
> 29.11.21 18:36, Victor Stinner пише:
> > You should consider "no longer have to justify why it's not optimized"
> > as a clear benefit of making this change :-) This optimization is
> > proposed once a year for many years...
> >
> > For me, any possible compilation-ahead optimization (which doesn't
> > break the Python semantics) is worth it ;-) It's done once, possible
> > even before the program is run for the first time, and then makes the
> > code faster.
>
> I consider the cost of rejecting such idea (this is actually the first
> time it was pushed so persistent) less than the cost of implementing and
> maintaining it. The proposed PR adds around 200 lines of code. It is
> almost 20% of the current size of ast_opt.c, it is not small. And just
> at first look I see a flaw in it -- it will emit a BytesWarning when
> compare strings and bytes. After fixing this the size will grow even
> more. And there may be other issues with this code which will be found
> months later. Later, when we rewrite the optimizer or change the
> structure of AST we will need to update this code too, with possibility
> to introduce new bugs.
>
> On other hand, the benefit of this optimization is exact zero. It does
> not make code faster, because it optimizes the code not used in real
> programs.
>
> _______________________________________________
> Python-Dev mailing list -- python-dev@python.org
> To unsubscribe send an email to python-dev-le...@python.org
> https://mail.python.org/mailman3/lists/python-dev.python.org/
> Message archived at 
> https://mail.python.org/archives/list/python-dev@python.org/message/LOIK6ZX43QHQSNWWUSE6YE3O5YBVGJOM/
> Code of Conduct: http://python.org/psf/codeofconduct/



-- 
Night gathers, and now my watch begins. It shall not end until my death.
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/7LEERBQSXAFRFZKRGHUDO4RMDI6GODLE/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to