[issue45975] Simplify some while-loops with walrus operator

2022-02-03 Thread miss-islington


miss-islington  added the comment:


New changeset cf7cb1a2bf40516dc571d1d90c12b632dcd9b8c8 by Miss Islington (bot) 
in branch '3.9':
bpo-45975: IDLE - Remove extraneous parens (GH-31107)
https://github.com/python/cpython/commit/cf7cb1a2bf40516dc571d1d90c12b632dcd9b8c8


--

___
Python tracker 

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



[issue45975] Simplify some while-loops with walrus operator

2022-02-03 Thread miss-islington


miss-islington  added the comment:


New changeset 63523e7b2a631f28134b25a8063d50e08c741db6 by Miss Islington (bot) 
in branch '3.10':
bpo-45975: IDLE - Remove extraneous parens (GH-31107)
https://github.com/python/cpython/commit/63523e7b2a631f28134b25a8063d50e08c741db6


--

___
Python tracker 

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



[issue45975] Simplify some while-loops with walrus operator

2022-02-03 Thread miss-islington


Change by miss-islington :


--
pull_requests: +29293
pull_request: https://github.com/python/cpython/pull/31110

___
Python tracker 

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



[issue45975] Simplify some while-loops with walrus operator

2022-02-03 Thread miss-islington


Change by miss-islington :


--
pull_requests: +29292
pull_request: https://github.com/python/cpython/pull/31109

___
Python tracker 

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



[issue45975] Simplify some while-loops with walrus operator

2022-02-03 Thread Terry J. Reedy


Terry J. Reedy  added the comment:


New changeset 916d0d822c79933f4c420f7a36f16f3eb788646b by Terry Jan Reedy in 
branch 'main':
bpo-45975: IDLE - Remove extraneous parens (GH-31107)
https://github.com/python/cpython/commit/916d0d822c79933f4c420f7a36f16f3eb788646b


--

___
Python tracker 

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



[issue45975] Simplify some while-loops with walrus operator

2022-02-03 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
pull_requests: +29290
pull_request: https://github.com/python/cpython/pull/31107

___
Python tracker 

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



[issue45975] Simplify some while-loops with walrus operator

2022-02-02 Thread Terry J. Reedy


Terry J. Reedy  added the comment:


New changeset fafd2dadf63973a04f5693e5be19f3e7521c10d4 by Terry Jan Reedy in 
branch '3.9':
[3.9] bpo-45975: Use walrus operator for some idlelib while loops (GH-31083)
https://github.com/python/cpython/commit/fafd2dadf63973a04f5693e5be19f3e7521c10d4


--

___
Python tracker 

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



[issue45975] Simplify some while-loops with walrus operator

2022-02-02 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
pull_requests: +29277
pull_request: https://github.com/python/cpython/pull/31092

___
Python tracker 

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



[issue45975] Simplify some while-loops with walrus operator

2022-02-02 Thread miss-islington


miss-islington  added the comment:


New changeset 2ddc278875f789de622262ee8ff5a1c3788f031c by Miss Islington (bot) 
in branch '3.10':
bpo-45975: Use walrus operator for some idlelib while loops (GH-31083)
https://github.com/python/cpython/commit/2ddc278875f789de622262ee8ff5a1c3788f031c


--

___
Python tracker 

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



[issue45975] Simplify some while-loops with walrus operator

2022-02-02 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 6.0 -> 7.0
pull_requests: +29276
pull_request: https://github.com/python/cpython/pull/31091

___
Python tracker 

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



[issue45975] Simplify some while-loops with walrus operator

2022-02-02 Thread Terry J. Reedy


Terry J. Reedy  added the comment:


New changeset 51a95be1d035a717ab29e98056b8831a98e61125 by Nick Drozd in branch 
'main':
bpo-45975: Use walrus operator for some idlelib while loops (GH-31083)
https://github.com/python/cpython/commit/51a95be1d035a717ab29e98056b8831a98e61125


--

___
Python tracker 

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



[issue45975] Simplify some while-loops with walrus operator

2022-02-02 Thread Nick Drozd


Change by Nick Drozd :


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

___
Python tracker 

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



[issue45975] Simplify some while-loops with walrus operator

2022-01-26 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

To me, the five idlelib changes make the code easier to understand.  Nick, 
please either move them into a separate PR or allow me to do so, and subject to 
manual testing, I will merge and backport.  (I requested this on the PR by 
maybe you missed it.)

If there are other plausible changes in idlelib that you would like considered, 
make a spinoff issue where we can discuss them first.

--
nosy: +terry.reedy

___
Python tracker 

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



[issue45975] Simplify some while-loops with walrus operator

2021-12-04 Thread Alex Waygood


Change by Alex Waygood :


--
nosy: +AlexWaygood

___
Python tracker 

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



[issue45975] Simplify some while-loops with walrus operator

2021-12-04 Thread Nick Drozd


Nick Drozd  added the comment:

> Is there any measurable performance benefit from this?

I wouldn't expect any performance changes either way. If it worked out to be 
slower, that would an unpleasant surprise and a good reason to reject this 
change. If it worked out to be faster, well, that would be great!

> Reducing several hundred thousand lines of code by 148 is not a compelling 
> benefit :)

But it's not just any old 148 lines. By my count it includes the removal of 47 
`break` statements. For a change of this nature there's certainly a chance of 
introducing errors. On the other hand, every one of those `break` statements is 
a site of manual loop-handling logic, and those already present some risk of 
introducing errors.

--

___
Python tracker 

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



[issue45975] Simplify some while-loops with walrus operator

2021-12-04 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

> As I mentioned in the PR, merging this can make future
> backports to 3.6 and 3.7 more complicated.

That's correct, but it is also true that we do very few of those and the 
likelihood of a conflict with one of these edits is low.

--

___
Python tracker 

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



[issue45975] Simplify some while-loops with walrus operator

2021-12-04 Thread Irit Katriel


Irit Katriel  added the comment:

As I mentioned in the PR, merging this can make future backports to 3.6 and 3.7 
more complicated.

--
nosy: +iritkatriel

___
Python tracker 

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



[issue45975] Simplify some while-loops with walrus operator

2021-12-03 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

The general rule as stated by Zachary is correct; however, I'm in mildly favor 
of this PR because these are the use cases that the walrus operator was 
specifically designed for.  That said, it would be nice to verify that timings 
don't get worse and to carefully review each edit to make sure it doesn't 
introduce a bug.

--
nosy: +rhettinger

___
Python tracker 

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



[issue45975] Simplify some while-loops with walrus operator

2021-12-03 Thread Zachary Ware


Zachary Ware  added the comment:

As a general rule, refactorings like this tend to be rejected as the risk of 
inadvertently adding a new bug outweighs the benefit of subjectively cleaner 
code ("if it ain't broke, don't fix it!").

Is there any measurable performance benefit from this? Reducing several hundred 
thousand lines of code by 148 is not a compelling benefit :)

--
nosy: +zach.ware

___
Python tracker 

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



[issue45975] Simplify some while-loops with walrus operator

2021-12-03 Thread Nick Drozd


New submission from Nick Drozd :

The following pattern occurs a few times in the codebase:

  while 1:
  data = conn.recv(blocksize)
  if not data:
  break
  ...

There is an unbounded while loop in which some kind of input is read. If the 
input is there, it is processed and the loop is continued; otherwise the loop 
is broken.

This can be expressed more cleanly with the walrus operator:

  while data := conn.recv(blocksize):
 ...

Some of this code goes back to the days of Python 1. I assume that the original 
authors would have used the walrus idiom if it had been available, which it 
wasn't. But now it is.

Rewriting the instances of this pattern shaves off 148 lines from the codebase. 
Removing the manual break statements makes the logic more straightforward.

This should not change the behavior of anything. I'm assuming that this code is 
all under test and that any deviations from the existing behavior will be 
caught. Anything that isn't tested shouldn't be changed (and should be tested).

--
components: Library (Lib)
messages: 407615
nosy: nickdrozd
priority: normal
pull_requests: 28133
severity: normal
status: open
title: Simplify some while-loops with walrus operator
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