This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

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

>>> 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

Changelog

2.5.3 (2017-02-10)

  • Fix use-after-free when repring a Struct that contains itself more than once.

2.5.2 (2016-04-07)

  • Fix make and tox targets for build and release.
  • Fix lint issues.

2.5.1 (2015-12-15)

  • Bugfix: Fix compilation of the _cstruct module.

2.5.0 (unreleased)

  • Build changes.

2.4.0 (2015-12-08)

  • Improvement: If a Struct subclass implements the __missing__ method, it will not be called before GetAttr on attribute access, but will be called before GetAttr on dict access.

2.3.1 (2015-12-07)

  • Bugfix: Clear KeyError in CStruct getattr before trying GetAttr, otherwise the KeyError may “leak out”. Also, only clear the error and attempt GetAttr if the original error was a KeyError.

2.3.0 (2015-12-02)

  • Add mixin class Frozen to make read-only versions of a dict-derived class (typically a Struct or a subclass there of.)
  • Use the Frozen mixin to implement FrozenStruct

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 (unreleased)

  • 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
Release History

Release History

2.5.3

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

2.5.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

2.5.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

2.5.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

2.3.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

2.2.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.3.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
tri.struct-2.5.3.tar.gz (15.9 kB) Copy SHA256 Checksum SHA256 Source Feb 10, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting