Skip to main content

destruct

Destruct is a tiny library to declaratively define data structures and parse them to Python objects.

The library is not mature by any means. Things may break, and API may significantly change in future.

https://secure.travis-ci.org/drdaeman/destruct.png?branch=master

Example

Data structures are declared in a manner somehow similar to Django models:

from destruct import StructBase
import destruct.fields as f

class MyStruct(StructBase):
    timestamp = f.TimestampField()
    value = f.U32Field()

Then, parsing is just creating object:

data = MyStruct(b"\0\0\0\0\0\0\0\xFF")
assert data.timestamp == datetime.datetime.utcfromtimestamp(0)
assert data.value == 255

Metadata

Release files for destruct 0.1.0

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

Source distribution (sdist)

Source distribution for destruct 0.1.0
File Size Uploaded
destruct-0.1.0.tar.gz 4.8 kB Details

Release files / destruct-0.1.0.tar.gz

Download URL destruct-0.1.0.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c8f1f972e2617e5a01841876a78211d024037b050712bf7737fd670717783cae
BLAKE2b-256 checksum
How to use checksums
dd414d3c211b512b79c47cb0247c92f2c2f874005d785148a87b9052b3699300
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file

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