Skip to main content
structpack
==========

A Python library for serializing and deserializing object trees to JSON-compatable values (dicts, lists, strings, ints, floats, bools).


Installation
------------

The recommended way to install structpack is with [pip](http://pypi.python.org/pypi/pip/):

pip install structpack


Examples
========

`structpack` is designed to be a base class (`msg`) that you inherit from and add properties to (`bool`, `int`, `float`, `string`, `list`, and `dict`).

The `msg` class adds methods `pack` and `load` which convert your object to and from native types, respectively.

The following is a trivial example of how to make a `Point` type using structpack

import structpack
class Point(structpack.msg):
x = structpack.float
y = structpack.float
z = structpack.float
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z

>>> p1 = Point(1., 2., 3.)
>>> data = p1.pack()
>>> print data
(1.0, 2.0, 3.0)

>>> p2 = Point.load(data)
>>> print p2
<__main__.Point object at 0x0000000001EDA390>
>>> print p2.x, p2.y, p2.z
1.0 2.0 3.0


More
----

Please see the [test suite](https://github.com/Knio/structpack/blob/master/tests/test_structpack.py) for more examples until they are documented here.


TODO
====

- Docs / examples
- Type check values
- Benchmark & optimize

Metadata

Release files for structpack 1.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 structpack 1.0.1
File Size Uploaded
structpack-1.0.1.zip 4.8 kB Details

Release files / structpack-1.0.1.zip

Download URL structpack-1.0.1.zip
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
1b14149986a72c32013a128bca2b64aa89cbe4c888325f7651b62dcbc5491e2b
BLAKE2b-256 checksum
How to use checksums
d150f83f32f870db816fbaba0cec83356019a1590884892a0d11e32f443ac550
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

1.6.0

1 release file

1.5.0

1 release file

1.4.0

1 release file

1.3.0

1 release file

1.2.0

1 release file

1.1.1

1 release file

1.1.0

1 release file

This release

1.0.1 This release

1 release file

0.2

1 release file

0.1

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