Make statusbar faster#286
Open
AlexKurek wants to merge 4 commits into
Open
Conversation
gmloose
reviewed
May 30, 2026
Collaborator
gmloose
left a comment
There was a problem hiding this comment.
I think it's OK to only update every 200 ms. I'm don't completely understand the other changes that I commented on.
| if self.max == 0: | ||
| sys.stdout.write(self.color + self.text + '[] 0/0\033[0m\n') | ||
| else: | ||
| # Recalculate comp in case the terminal size (self.columns) has changed |
Collaborator
There was a problem hiding this comment.
Comment doesn't match with the conditional (self.max != 0). So either the comment or the code is incorrect. Also, it's not completely clear for me why you moved this line from the increment() method into the __print() method.
Contributor
Author
There was a problem hiding this comment.
We want the progress bar to handle terminal resizing at any moment, so the calculation of self.comp must always happen immediately after checking the terminal size.
If/else is there to prevent division by zero error.
This reverts commit 6ef786f.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This does not require an extensive testing, since I havent touched computations. Just look at
ncallsand it explains everything. Now printing and checking the terminal size occurs only 5x / sec.For a 1.5 GB FITS:
before:
after:
This 3 functions are 52x faster.
The entire run is 2.6% faster.