progress icon indicating copy to clipboard operation
progress copied to clipboard

next function taking an optional value of steps

Open delbertaud opened this issue 3 years ago • 2 comments

I've noticed while processing a large run (number of iterations) that refreshing the progress bar with a bar.next() on each causes a delay. It might be of value to add an optional incoming attribute of the next function that would just the bar forward x steps without refreshing the bar on each step. Example if I'm iterating over 1,000,000 items in a list but only wish to refresh the progress bar every 1,000 making a bar.next(1000) would be efficient.

delbertaud avatar Mar 22 '21 19:03 delbertaud

Sorry this is a case of not reading the code. I have found bar.goto(1000) solves this issue.

delbertaud avatar Mar 22 '21 19:03 delbertaud

bar.next() does take an optional argument n which defaults to 1 and specifies the amount to increment the bar's index by (https://github.com/verigak/progress/blob/master/progress/init.py#L123).

So you can do:

with progress.bar.Bar('Progress', max=10**6) as bar:
    for i in range(10**6):
        if i % 100 == 0: bar.next(100)
        # Do some calculation with i

MarkCBell avatar Apr 13 '21 10:04 MarkCBell