[Python-Dev] Re: Optimizing literal comparisons and contains

2021年11月28日 13:13:27 -0800

> On Nov 28, 2021, at 3:03 PM, Serhiy Storchaka <[email protected]> wrote:
> 
> 28.11.21 17:13, Skip Montanaro пише:
>>> That is not entirely true: 
>>> https://github.com/python/cpython/pull/29639#issuecomment-974146979
>> 
>> The only places I've seen "if 0:" or "if False:" in live code was for
>> debugging. Optimizing that hardly seems necessary. In any case, the
>> original comment was about comparisons of two constants. I suppose
>> sweeping up all of that into a constant expression folding/elimination
>> step performed on the AST and/or during peephole optimization would
>> cover both cases.
> 
> "if 0:" and "if False:" is already optimized by the compiler. The OP
> proposes to optimize "2 < 1", and I cannot imagine any use case for this.
I agree. I suggest we don’t add this optimization. 
Eric
_______________________________________________
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/JP6FF2RHDQSIOS6ZAI45S7X6UXWGPBKR/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to