'tqdm progress bar that predicts progress of long iterations

I have a loop that does a long calculation many times that I would like to track the progress of. 53.28s/it

However this setup with tqdm is quite impractical. tqdm will only update the progress bar (elapsed and estimated time, and percent progression) when an iteration has finished, even though the calculation time is consistent.

The calculation has an iteration loop inside it too that I could wrap in tqdm, but this one actually has inconsistent time (slow in the beginning and fast in the end), so it would mess with the time estimate of the outer loop.

How can I make tqdm predict the progress without receiving updates?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source