I also agree with this analysis. I’ll just add that any discussion about optimization needs to also show some data, for let’s say both contrived examples (like this one IMHO) and as real-world examples as possible. Sometimes “obvious” optimizations fool you and things actually get slower. Or they don’t speed things up as much as you think they will.
Optimizations usually involve adding complexity. I would like some sense of what we’d gain for the added complexity. Cheers, -Barry > On Nov 29, 2021, at 09:04, 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/
signature.asc
Description: Message signed with OpenPGP
_______________________________________________ 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/TZTA3NVDEKUMGZTK6QDD4R6F36E4NVMM/ Code of Conduct: http://python.org/psf/codeofconduct/