Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

next function taking an optional value of steps #94

Open
delbertaud opened this issue Mar 22, 2021 · 2 comments
Open

next function taking an optional value of steps #94

delbertaud opened this issue Mar 22, 2021 · 2 comments

Comments

@delbertaud
Copy link

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
Copy link
Author

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

@MarkCBell
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants