BTW: I could already make it faster, by not repeatedly accessing .arg anymore. It went down from ca.:
171'000 ms To this here: 140'000 ms But only in the cold run. In the warm run it went back to 171'000 ms. Possibly when my code is faster, it will create objects more faster, and kill the Python GC. Or it was because my Laptop went into screen black? And throttled the CPU. Not sure. Mostowski Collapse schrieb am Mittwoch, 15. September 2021 um 23:13:12 UTC+2: > Ok you suggested: > >>>items = [1,2,3,4,5,6,7,8,9,0] > >>>for item in items[:-1]: > >>> print(item) > > 1 > 2 > 3 > 4 > 5 > 6 > 7 > 8 > 9 > Does this also work for length = 1? Ok let me try: > >>> foo = ["a","b","c"] > >>> for x in foo[:-1]: > ... print(x) > ... > a > b > >>> foo = ["a"] > >>> for x in foo[:-1]: > ... print(x) > ... > > Oki Doki > Mostowski Collapse schrieb am Mittwoch, 15. September 2021 um 23:10:50 UTC+2: > > And how do you only iterate over n-1 elements? > > I don't need a loop over all elements. > > > > With array slicing? > > > > Someting like: > > > > for item in items[0:len(items)-2]: > > ___print(item) > > > > Or with negative slicing indexes? Problem > > is my length can be equal to one. > > > > And when I have length equal to one, the > > slice might not do the right thing? > > > > LoL > > alister schrieb am Mittwoch, 15. September 2021 um 22:00:30 UTC+2: > > > for item in items: > > > print(item) -- https://mail.python.org/mailman/listinfo/python-list