[issue45907] Optimize literal comparisons and contains

2021-11-27 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

On the other hand, we can probably just remove the TODO

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45907] Optimize literal comparisons and contains

2021-11-27 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

I agree with Serhiy and Batuhan. Please reach to python-dev of you really want 
to pursue this even after what has been already discussed.

--
resolution:  -> rejected
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45907] Optimize literal comparisons and contains

2021-11-27 Thread Batuhan Taskaya


Batuhan Taskaya  added the comment:

We just rejected the same issue 2 days ago. If you feel very strong about this; 
instead of creating new ticket in the same place, you might want to try 
python-dev instead. 

Re: the todo comment, feel free to send a patch that removes it. I don't thank 
that is still applicable.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45907] Optimize literal comparisons and contains

2021-11-27 Thread theeshallnotknowethme


theeshallnotknowethme  added the comment:

List and sets as right operands in literal contains are optimized to constant 
tuples and frozensets, and I'd like to take this optimization a step further.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45907] Optimize literal comparisons and contains

2021-11-27 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

> It doesn't seem to make sense why other operations on literals are optimized 
> but these particular ones aren't optimized (much).

The existing optimizer optimizes the following cases (note that the parser does 
not produce negative or complex numbers, they are created by the optimizer):

   -1
   1-2j
   1/3
   16*1024
   2**32-1
   1<<12
   b'a'[0]

They all are extremely common. Virtually every Python file contain some of such 
expressions, and they are often used in loops. In contrary, it is difficult to 
find any example of using comparison operations with all constant operands.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45907] Optimize literal comparisons and contains

2021-11-26 Thread theeshallnotknowethme


theeshallnotknowethme  added the comment:

If this bug report isn't accepted, for how long would the TODO remain in 
`Python/ast_opt.c`?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45907] Optimize literal comparisons and contains

2021-11-26 Thread theeshallnotknowethme


theeshallnotknowethme  added the comment:

It doesn't seem to make sense why other operations on literals are optimized 
but these particular ones aren't optimized (much).

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45907] Optimize literal comparisons and contains

2021-11-26 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

This PR looks to be the same as one that was recently rejected.

Compare:
   https://github.com/python/cpython/pull/29639/files
   https://github.com/python/cpython/pull/29810/files

See discussion at:
   https://bugs.python.org/issue45843

--
nosy: +BTaskaya, pablogsal, rhettinger, serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45907] Optimize literal comparisons and contains

2021-11-26 Thread theeshallnotknowethme


Change by theeshallnotknowethme :


--
keywords: +patch
pull_requests: +28042
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/29810

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45907] Optimize literal comparisons and contains

2021-11-26 Thread theeshallnotknowethme


New submission from theeshallnotknowethme :

Most operations with literals are optimized as well, so why shouldn't the 
comparison/contain operators be? I created a new bug report for it because of 
this fact and the TODO in the `fold_compare` function in `Python/ast_opt.c`.

--
components: Interpreter Core
messages: 407114
nosy: February291948
priority: normal
severity: normal
status: open
title: Optimize literal comparisons and contains
type: performance
versions: Python 3.11

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com