Table of Contents

Module: EigenData ./src/peak/util/EigenData.py

Objects that can be written, unless they've been read

Dynamic configuration can be a wonderful thing. It can also be a nightmare, if you have configuration values that depend on other configuration values, and you are using lots of components that are reading and writing those values. If you change a value after it has already been used by another component, how can you be sure what objects were configured in what way?

Different languages and systems approach this issue differently. In Java, it's common to have settings which can be set only once. In Python, one may use immutables. Zope 3X has a configuration conflict detection algorithm. But all of these approaches depend on either a write-once approach or an atomic configuration phase.

PEAK takes a "quantum physics" approach to immutability instead: treat configuration data as an opaque box, whose contents you can change at will. However, once somebody looks in the box, the result is fixed and can no longer be changed. You can think of it as a kind of "lazy immutability".

The EigenData module supplies an EigenCell class for storing single values, and an EigenDict class to be used in place of dictionaries. Modifying an EigenCell or EigenDict once it has been read results in an AlreadyRead exception. Also available: CollapsedCell, which is an empty EigenCell that has already been read and is therefore immutable.

FYI: the module and classes are named after eigenstates in quantum physics; "one of a finite number of states that a quantum system can be in". The famous "Schrodinger's Cat" thought experiment is an analogy for eigenstates: once the box is opened, its contents are forced to collapse to a single eigenstate. SchrodingDict and SchrodingCell, however, are much more awkward to say and type!

Imported modules   
from protocols import Interface
Classes   

AlreadyRead

Key or value has already been read

EigenCell

Hold a value which can be changed as long as it has not been examined

EigenDict

Mapping whose entries can be changed as long as they are unread


Table of Contents

This document was automatically generated on Mon Jun 17 01:11:14 2019 by HappyDoc version 2.1