Skip to main content

aspen-dynamo

Async DynamoDB table helper built on aioboto3. It wraps a DynamoDB table resource with small conveniences for key handling, pagination, and optional Pydantic model validation.

Installation

pip install aspen-dynamo

Optional extras:

pip install "aspen-dynamo[benchmark]"

Usage

Create a DynamoDBTable with a boto3 DynamoDB resource:

import aioboto3
from aspen_dynamo import DynamoDBTable

session = aioboto3.Session()

async with session.resource("dynamodb") as resource:
    table = DynamoDBTable("MyTable", "pk", resource=resource)
    item = await table.get_item(123)
    print(item)

Partition + sort key (composite key)

Pass a tuple of attribute names for a table with a partition key and sort key:

import aioboto3
from aspen_dynamo import DynamoDBTable

session = aioboto3.Session()

async with session.resource("dynamodb") as resource:
    table = DynamoDBTable("MyTable", ("pk", "sk"), resource=resource)
    item = await table.get_item(123, "v1")
    print(item)

Usage with a Pydantic model

Provide a model to coerce DynamoDB items into typed objects:

import aioboto3
from pydantic import BaseModel
from aspen_dynamo import DynamoDBTable

class Widget(BaseModel):
    pk: int
    name: str

session = aioboto3.Session()

async with session.resource("dynamodb") as resource:
    table = DynamoDBTable("MyTable", "pk", resource=resource, model=Widget)
    widget = await table.get_item(123)
    print(widget.name)

Benchmark

The benchmark.py script compares aspen-dynamo to other async DynamoDB clients. It uses the same DynamoDBTable API as above:

python -m aspen_dynamo.benchmark MyTable pk 123

Results from two runs:

  • uvloop 0.19.0
  • aioboto3 13.0.0
  • aiobotocore 2.13.0
  • aiodynamo 24.7
  • aiohttp 3.9.5
  • boto3 1.34.106
  • httpx 0.28.1
Test Avg latency 1 Avg latency 2 CPU time 1 CPU time 2
aioboto3 (client) 3.12ms 2.67ms 0.75ms 0.71ms
aioboto3 (resource) 3.39ms 2.64ms 0.80ms 0.78ms
aspen-dynamo 2.61ms 3.24ms 0.78ms 0.79ms
raw request (aiohttp) 2.43ms 2.17ms 0.26ms 0.28ms
aiodynamo (aiohttp) 2.34ms 2.15ms 0.32ms 0.32ms
raw request (httpx) 2.53ms 2.54ms 2.05ms 1.99ms
aiodynamo (httpx) 3.02ms 3.01ms 2.07ms 2.23ms

Metadata

Release files for aspen-dynamo 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aspen-dynamo 0.1.3
File Size Uploaded
aspen_dynamo-0.1.3.tar.gz 8.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aspen-dynamo 0.1.3
File Interpreter ABI Platform
aspen_dynamo-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 14.8 kB

Release files / aspen_dynamo-0.1.3.tar.gz

Download URL aspen_dynamo-0.1.3.tar.gz
Size 8.3 kB
Tags Source
SHA-256 checksum
How to use checksums
08daee7a74418892f15e5e60ca076b0ae29f36704f726abb3cb265158bc46017
BLAKE2b-256 checksum
How to use checksums
02e6031bf50ffeff733f01f5eac4acfc785e269e83ba4263d036310062bc3226
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release files / aspen_dynamo-0.1.3-py3-none-any.whl

Download URL aspen_dynamo-0.1.3-py3-none-any.whl
Size 6.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fd86cd8d7c88f9ee8d3c5b352981a8212a30365add3dd266675dd8744b76d572
BLAKE2b-256 checksum
How to use checksums
c31a29dd796a656d83297d84acbec773a6bd8fb72769f97075024f535f9d81c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.0

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page