Discussion:
[PEAK] understanding the trellis code
nicky van foreest
2011-06-21 23:05:52 UTC
Permalink
Hi,

Some time ago I discovered Trellis to solve some of my problems with
updating data in classes I use for simulations and numerical
experiments. Now I would like to understand the Trellis code somewhat
better, mostly out of curiosity and to improve my python skills. The
code, however, is not particularly revealing, at least not for me.
Does anybody have some tips where to begin? Otherwise, what algorithm
is used to check and setup the dependencies between the attributes?
If I were to build this myself I think I would use some sort of
dependency graph. But I cannot find this anywhere in the code. What
ideas are used in Trellis to do this?

bye

Nicky
P.J. Eby
2011-06-23 04:03:32 UTC
Permalink
Post by nicky van foreest
Hi,
Some time ago I discovered Trellis to solve some of my problems with
updating data in classes I use for simulations and numerical
experiments. Now I would like to understand the Trellis code somewhat
better, mostly out of curiosity and to improve my python skills. The
code, however, is not particularly revealing, at least not for me.
Does anybody have some tips where to begin? Otherwise, what algorithm
is used to check and setup the dependencies between the attributes?
If I were to build this myself I think I would use some sort of
dependency graph. But I cannot find this anywhere in the code.
The dependency graph is implemented via bidirectional linked lists
between AbstractSubject and AbstractListener in peak.events.stm.

Both Subjects and Listeners can iterate their opposite ends, and a
graph edge is created by simply invoking:

Link(subject, listener)

The Link object is a weak reference to the listener (so that the link
disappears if the listener is garbage collected) and holds a strong
(normal) reference to the subject so the subject stays alive as long
as listeners still exist.

A Trellis cell can be both a subject and a listener, thus making the
graph transitive. Cells also have a level attribute that indicates
their distance from the graph roots.

Loading...