or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

core.mdenvironments.mdindex.mdintegrations.mdparallel.mdutilities.md
tile.json

tessl/pypi-tqdm

Fast, extensible progress meter for loops and iterators in Python

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/tqdm@4.67.x

To install, run

npx @tessl/cli install tessl/pypi-tqdm@4.67.0

index.mddocs/

tqdm

A fast, extensible progress meter for loops and iterators in Python. tqdm wraps any iterable to create smart progress bars with minimal overhead (60ns per iteration) and works across all environments including terminals, GUIs, and Jupyter notebooks.

Package Information

  • Package Name: tqdm
  • Version: 4.67.1
  • Language: Python
  • Installation: pip install tqdm
  • Dependencies: None (optional: colorama on Windows)
  • License: MPL-2.0 AND MIT
  • Python Support: 3.7+
  • Homepage: https://tqdm.github.io
  • Repository: https://github.com/tqdm/tqdm

Core Imports

from tqdm import tqdm, trange

For specific environments and integrations:

from tqdm.auto import tqdm, trange              # Auto-detects best variant
from tqdm.notebook import tqdm, trange          # Jupyter notebooks
from tqdm.asyncio import tqdm, trange           # Async/await support
from tqdm.gui import tqdm, trange              # Matplotlib GUI
from tqdm.rich import tqdm, trange             # Rich integration
from tqdm.contrib.concurrent import thread_map, process_map  # Parallel processing

Basic Usage

from tqdm import tqdm, trange
import time

# Wrap any iterable
for i in tqdm(range(10000)):
    time.sleep(0.0001)  # Simulate work

# Range shortcut
for i in trange(10000, desc="Processing"):
    time.sleep(0.0001)

# Manual updates
pbar = tqdm(total=100)
for i in range(100):
    time.sleep(0.01)
    pbar.update(1)
pbar.close()

# Context manager
with tqdm(total=100) as pbar:
    for i in range(100):
        time.sleep(0.01)
        pbar.update(1)

# Custom formatting
for i in tqdm(range(1000), desc="Training", unit="batch", 
              bar_format="{l_bar}{bar:30}{r_bar}"):
    time.sleep(0.001)

Architecture

tqdm uses a modular architecture enabling extensive customization and multiple interfaces:

  • Core Engine (tqdm.std): Foundation progress bar with format strings, timing, and display logic
  • Environment Variants: Specialized implementations for different contexts (CLI, notebooks, GUI, async)
  • Integration Modules: Extensions for popular frameworks (Keras, Dask, Pandas)
  • Utility Classes: Thread-safe I/O wrappers, monitoring threads, and helper functions
  • Contrib Package: Additional tools for parallel processing, itertools integration, and external services

This design allows tqdm to automatically adapt to any environment while providing consistent APIs across all variants.

Capabilities

Core Progress Bars

Essential progress bar functionality including iterator wrapping, manual updates, customizable formatting, and context manager support. Forms the foundation for all tqdm variants.

class tqdm(Comparable):
    def __init__(self, iterable=None, desc=None, total=None, leave=True, 
                 file=None, ncols=None, mininterval=0.1, maxinterval=10.0,
                 miniters=None, ascii=None, disable=False, unit='it',
                 unit_scale=False, dynamic_ncols=False, smoothing=0.3,
                 bar_format=None, initial=0, position=None, postfix=None,
                 unit_divisor=1000, write_bytes=None, lock_args=None,
                 nrows=None, colour=None, delay=0, gui=False, **kwargs): ...
    
    def update(self, n=1): ...
    def close(self): ...
    def set_description(self, desc=None, refresh=True): ...
    def set_postfix(self, ordered_dict=None, refresh=True, **kwargs): ...

def trange(*args, **kwargs): ...

Core Progress Bars

Environment Variants

Specialized progress bar implementations for different environments including automatic selection, Jupyter notebooks, async/await support, and GUI interfaces.

# Auto-detection
from tqdm.auto import tqdm, trange

# Jupyter notebooks  
from tqdm.notebook import tqdm as notebook_tqdm, trange as notebook_trange

# Async support
from tqdm.asyncio import tqdm as async_tqdm, trange as async_trange

# GUI variants
from tqdm.gui import tqdm as gui_tqdm
from tqdm.rich import tqdm as rich_tqdm

Environment Variants

Framework Integrations

Integration modules for popular Python frameworks including Keras callbacks, Dask computation tracking, and pandas DataFrame operations.

# Keras integration
from tqdm.keras import TqdmCallback

# Dask integration  
from tqdm.dask import TqdmCallback

# Pandas integration
tqdm.pandas()  # Enables .progress_apply() methods

Framework Integrations

Parallel Processing

Utilities for parallel processing with progress tracking including thread-based and process-based mapping functions with automatic progress bars.

from tqdm.contrib.concurrent import thread_map, process_map

def thread_map(fn, *iterables, max_workers=None, chunksize=1, **tqdm_kwargs): ...
def process_map(fn, *iterables, max_workers=None, chunksize=1, **tqdm_kwargs): ...

Parallel Processing

Utilities and Extensions

Additional utilities including iterator helpers, logging integration, external service notifications, and low-level I/O wrappers for advanced use cases.

from tqdm.contrib import tenumerate, tzip, tmap
from tqdm.contrib.logging import tqdm_logging_redirect
from tqdm.utils import FormatReplace, CallbackIOWrapper

Utilities and Extensions

Common Patterns

Progress Bar Customization

# Custom description and units
for i in tqdm(range(1000), desc="Processing items", unit="item"):
    pass

# Custom bar format
for i in tqdm(range(1000), 
              bar_format="{desc}: {percentage:3.0f}%|{bar}| {n_fmt}/{total_fmt}"):
    pass

# Dynamic postfix updates
pbar = tqdm(range(1000))
for i in pbar:
    pbar.set_postfix({"loss": f"{i*0.001:.3f}", "accuracy": f"{95+i*0.01:.1f}%"})

Multiple Progress Bars

from tqdm import tqdm
import time

# Sequential bars
for epoch in trange(5, desc="Epochs"):
    for batch in trange(100, desc="Batches", leave=False):
        time.sleep(0.01)

# Nested bars with position
outer = tqdm(range(5), desc="Outer", position=0)
for i in outer:
    inner = tqdm(range(100), desc=f"Inner {i}", position=1, leave=False)
    for j in inner:
        time.sleep(0.001)
    inner.close()
outer.close()

Error Handling

from tqdm import TqdmWarning, TqdmKeyError
import warnings

# Handle tqdm-specific warnings
with warnings.catch_warnings():
    warnings.simplefilter("ignore", TqdmWarning)
    # Your tqdm code here

# Exception handling
try:
    pbar = tqdm(total=100)
    # Progress bar operations
except TqdmKeyError as e:
    print(f"Configuration error: {e}")
finally:
    pbar.close()