Skip to main content

DataLoader implementation for Python asyncio

Project description

dloader

A Python implementation of the DataLoader pattern for data fetching with automatic batching.

Features

  • Automatically batches and deduplicates concurrent loads
  • Caches results and allows custom in-memory caches
  • Manages asyncio tasks and allows proper cleanup
  • Small, focused and free of other dependencies
  • Fully typed and fully tested

Installation

uv add dloader
# or
pip install dloader

Documentation

You can find documentation at: https://oinopion.github.io/dloader

Quick Start

import asyncio
from dloader import DataLoader

# Define a batch loading function
async def batch_load_users(user_ids):
    # Fetch multiple users at once (e.g., from a database)
    users = await db_client.get_many(User, user_ids)
    return users

# Create a DataLoader instance
async with DataLoader(batch_load_users) as user_loader:
    # These calls are automatically batched
    user_1, user_2, other_users = await asyncio.gather(
        user_loader.load(1),
        user_loader.load(2),
        user_loader.load_many([3, 4, 5]),
    )

Versioning

This project follows CalVer. Expect couple of release per year with very minor changes.

License

MIT License - see LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dloader-2025.7.tar.gz (35.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dloader-2025.7-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file dloader-2025.7.tar.gz.

File metadata

  • Download URL: dloader-2025.7.tar.gz
  • Upload date:
  • Size: 35.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.8.3

File hashes

Hashes for dloader-2025.7.tar.gz
Algorithm Hash digest
SHA256 1f81f6fc7125e41dec4463c51b25abc881af858cdc0152681c49cefb15b29651
MD5 adcae5c122e869b71c252bb28d2b8d69
BLAKE2b-256 d534d08841fb784bbe9a95d6be66f41abed190a2ffbfc419ded1b18dc92bb93f

See more details on using hashes here.

File details

Details for the file dloader-2025.7-py3-none-any.whl.

File metadata

  • Download URL: dloader-2025.7-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.8.3

File hashes

Hashes for dloader-2025.7-py3-none-any.whl
Algorithm Hash digest
SHA256 fb39bd828a7c7d03a88dede85cf7b6bffc2c39b0d5aabaea5cce376d220faf74
MD5 123605ed56fdf283d13c97baa94b760c
BLAKE2b-256 0b9a9c1e2bc0e4af4fb5a6e0a3684abd649b35e64d7793fb3b2cf282145a68d1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page