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

Support lazy writing #56

Open
bstanden opened this issue Oct 10, 2018 · 2 comments
Open

Support lazy writing #56

bstanden opened this issue Oct 10, 2018 · 2 comments

Comments

@bstanden
Copy link

Every call to update() causes the progress bar to produce output. If I'm using a Bar to track a loop of millions of iterations then my terminal is flooded with output even though the progress bar itself doesn't need to change.

Perhaps add an option lazy_write which, if true, causes writeln to remember what it last wrote - and if it's no different, it doesn't write anything to the terminal.

@hargikas
Copy link

Really good point! Especially useful on working on large iterators (using the generator iter()).

@danizen
Copy link

danizen commented Dec 10, 2020

I think the easiest way to do something like this is to allow the user to pass a blocking factor to any Progress. This would change the operation of progress.next() so that self.index is always updated, but progress is only printed it this is the first call or if (self.index % self.bf) == 0. Similarly, this would also mean fewer calls to time.monotonic() and so on.

While time.perf_counter() is no longer a system call, I am not at all sure about time.monotonic(), since it is still supposed to be a time.

The calling convention could be to pass a block_size:

bar = Bar(max=result_count, block_size=4096)

For now, I am doing this above progress.Bar altogether as follows:

count += 1
if bar and (count % 4096)==0:
    bar.next(4096)

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

3 participants