tqdm
The tqdm
module allows for the generation of progress bars in Python. The name is derived from the Arabic word, “taqaddum,” which translates as “progress.” It is designed to have minimal overhead, using algorithms to predict the remaining time and to skip unnecessary iteration displays. It has about a 60ns (nanoseconds) overhead per iteration whereas other progress bar implementations can run an 800ns overhead per iteration. tqdm
does not require any dependencies.
Note:
tqdm
requires an environment that supports carriage return (\r
) and line feed (\n
) control characters.
Installation
tqdm
can be installed with the following pip command:
pip install tqdm
Example
The most straightforward way to use tqdm
is to wrap the tqdm()
function around any iterable:
from tqdm import tqdmfrom time import sleeptotal = 0for num in tqdm([1, 2, 3, 4]):sleep(0.25)total = total + numprint("done")
This results in output like the following:
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn Python on Codecademy
- Career path
Computer Science
Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!Includes 6 CoursesWith Professional CertificationBeginner Friendly75 hours - Course
Learn Python 3
Learn the basics of Python 3.12, one of the most powerful, versatile, and in-demand programming languages today.With CertificateBeginner Friendly23 hours