tri.struct supplies classes that can be used like dictionaries and as objects with attribute access at the same time
Project description
.. image:: https://travis-ci.org/TriOptima/tri.struct.svg?branch=master
:target: https://travis-ci.org/TriOptima/tri.struct
.. image:: http://codecov.io/github/TriOptima/tri.struct/coverage.svg?branch=master
:target: http://codecov.io/github/TriOptima/tri.struct?branch=master
tri.struct
==========
tri.struct supplies classes that can be used like dictionaries and as objects with attribute access at the same time. There are two versions:
- Struct: mutable struct
- FrozenStruct: immutable struct
Some niceties include:
- Predictable repr() so it's easy to write tests
- `merged` function call to merge different types of dicts into a new: `merged(Struct(a=1), FrozenStruct(b=1), c=1) == Struct(a=1, b=1, c=1)`)
- Accelerated implementation in c for improved speed. (With python-only fallback reference implementation)
Example
-------
.. code:: python
>>> foo = Struct()
>>> foo.a = 1
>>> foo['a']
1
>>> foo['a'] = 2
>>> foo.a
2
Running tests
-------------
You need tox installed then just `make test`.
License
-------
BSD
Documentation
-------------
http://tristruct.readthedocs.org.
Changelog
=========
2.2.0 - 2015-11-12
* Add keyword arguments to `merged` function.
2.1.2 - 2015-11-11
~~~~~~~~~~~~~~~~~~
* Redo the C implementation to be a "heaptype", and remove the hack of
setting `__dict__` = `self`. Instead, `object` will control the type
storage, letting us "insert" attributes into the object without
polluting the `dict`.
2.0 - (never released)
~~~~~~~~~~~~~~~~~~~~~~
* slim down interface to again match dict
* add tri.struct.merged function to join structs
* add optional C implementation to speed up instantiation
1.0 - 2015-09-29
~~~~~~~~~~~~~~~~
* Struct with attribute & dict interface
* __add__ and __or__ to combine structs
:target: https://travis-ci.org/TriOptima/tri.struct
.. image:: http://codecov.io/github/TriOptima/tri.struct/coverage.svg?branch=master
:target: http://codecov.io/github/TriOptima/tri.struct?branch=master
tri.struct
==========
tri.struct supplies classes that can be used like dictionaries and as objects with attribute access at the same time. There are two versions:
- Struct: mutable struct
- FrozenStruct: immutable struct
Some niceties include:
- Predictable repr() so it's easy to write tests
- `merged` function call to merge different types of dicts into a new: `merged(Struct(a=1), FrozenStruct(b=1), c=1) == Struct(a=1, b=1, c=1)`)
- Accelerated implementation in c for improved speed. (With python-only fallback reference implementation)
Example
-------
.. code:: python
>>> foo = Struct()
>>> foo.a = 1
>>> foo['a']
1
>>> foo['a'] = 2
>>> foo.a
2
Running tests
-------------
You need tox installed then just `make test`.
License
-------
BSD
Documentation
-------------
http://tristruct.readthedocs.org.
Changelog
=========
2.2.0 - 2015-11-12
* Add keyword arguments to `merged` function.
2.1.2 - 2015-11-11
~~~~~~~~~~~~~~~~~~
* Redo the C implementation to be a "heaptype", and remove the hack of
setting `__dict__` = `self`. Instead, `object` will control the type
storage, letting us "insert" attributes into the object without
polluting the `dict`.
2.0 - (never released)
~~~~~~~~~~~~~~~~~~~~~~
* slim down interface to again match dict
* add tri.struct.merged function to join structs
* add optional C implementation to speed up instantiation
1.0 - 2015-09-29
~~~~~~~~~~~~~~~~
* Struct with attribute & dict interface
* __add__ and __or__ to combine structs
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for tri.struct-2.2.0-py2.7-macosx-10.10-x86_64.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | c991d103900fc29b473e43dfa517a34d469a639fa8bf404d9229913339b429e8 |
|
MD5 | e18294a5ffe29ce0a0f6d54b193dde1f |
|
BLAKE2b-256 | a22c2fdf6b0e3b0efb3a42c364b7e874c15c3344109b3107ee9dc3eaa30e438d |