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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f81f6fc7125e41dec4463c51b25abc881af858cdc0152681c49cefb15b29651
|
|
| MD5 |
adcae5c122e869b71c252bb28d2b8d69
|
|
| BLAKE2b-256 |
d534d08841fb784bbe9a95d6be66f41abed190a2ffbfc419ded1b18dc92bb93f
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb39bd828a7c7d03a88dede85cf7b6bffc2c39b0d5aabaea5cce376d220faf74
|
|
| MD5 |
123605ed56fdf283d13c97baa94b760c
|
|
| BLAKE2b-256 |
0b9a9c1e2bc0e4af4fb5a6e0a3684abd649b35e64d7793fb3b2cf282145a68d1
|