Skip to main content

lazydataclasses

Dataclass constructor, but lazier.

This module exposes a decorator @dataclass that should return a class that looks like, smells like, behaves like a dataclasses.dataclass. The difference (for our purposes) is that its __dataclass_fields__ are loaded lazily rather than at import time. This speeds up imports by around 5x at the expense of slowing down init time (around 10x slower).

pip install lazydataclasses

Compatability/Completeness

Included are a copy of the stdlib tests as of 3.14.

Most stuff passes, however the following features are unsupported:

  • No __slots__ support.
  • Some errors have moved from class-creation time to field-lookup time. Everywhere dataclasses.fields(...) appears it is because there is an error that no longer appears at class-creation time, most methods (eg. __init__) do a field-lookup, so these should eventually get raised.
  • No InitVar support. This is pure laziness, I've never seen one in the wild.
  • No generated docstring support, again pure laziness.
  • inspect.signature(MyDataclass.__init__) no longer works the same as the methods aren't codegenned at import time, there are *args, **kwargs.
  • A few other very small things - see @pytest.mark.xfail.

Development

uv run pytest
uv run mypy src tests --strict

Updating test suite

rm -r tests/test_dataclasses
curl 'https://github.com/python/cpython/archive/refs/tags/v3.14.0b3.zip'
unzip ...
cp -r ../cpython/Lib/test/test_dataclasses tests/
mv tests/test_dataclasses/__init__.py tests/test_dataclasses/test_stdlib.py
# add `from lazydataclasses import dataclass` import below `from dataclasses import *`

Metadata

Release files for lazydataclasses 0.0.1

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

Source distribution (sdist)

Source distribution for lazydataclasses 0.0.1
File Size Uploaded Provenance
lazydataclasses-0.0.1.tar.gz 4.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for lazydataclasses 0.0.1
File Interpreter ABI Platform
lazydataclasses-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 10.6 kB

Release files / lazydataclasses-0.0.1.tar.gz

Download URL lazydataclasses-0.0.1.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
95002ddb58d74d73c5cdcbe9712489b8b642425a06b25954332391da04ab80f7
BLAKE2b-256 checksum
How to use checksums
5bcb0861eb37bf7582690c458c884ffab542ba850ba5d02c5b34d9ac93e6a133
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / lazydataclasses-0.0.1-py3-none-any.whl

Download URL lazydataclasses-0.0.1-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
62d4cd57e21593668b6aead24aae653b367b322f468fb327ba365fb21f29ada4
BLAKE2b-256 checksum
How to use checksums
8cd78356281501ce5550dd87ec47c4a83d13f8fa3963f3dc4c52d8e00c0b1643
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for lazydataclasses 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

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