[issue45579] [list.append(i) for i in list] causes high resources usage

2021-10-23 Thread Raymond Hettinger
Change by Raymond Hettinger : -- resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker ___ ___

[issue45579] [list.append(i) for i in list] causes high resources usage

2021-10-23 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: It is expected behavior. Your code is equivalent to: _result = [] for i in your_list: _result.append(your_list.append(i)) which is equivalent to: _result = [] _j = 0 while _j < len(your_list): i = your_list[_j]

[issue45579] [list.append(i) for i in list] causes high resources usage

2021-10-22 Thread Spencer Brown
Spencer Brown added the comment: This is intentional behaviour, you actually created an infinite loop. When you iterate over a list, all Python does is track the current index through the list internally, incrementing it each time. But each iteration, you call list.append() to add a new

[issue45579] [list.append(i) for i in list] causes high resources usage

2021-10-22 Thread TL
New submission from TL : Version: Python 3.10.0 - Windows 11 (22000.258) x64 Python 3.9.7 - Windows 11, Manjaro Linux 21.1.5 - Kernel 5.13.13-1-MANJARO x64 CPU: 8 × Intel® Core™ i5-8300H CPU @ 2.30GHz Steps to reproduce: 1. Create any list, for example your_list = [1, 2, 3] 2. Execute