PuPPy is a lightweight push-pull model based on the automation proposed in [1, 2]. It allows programmers to choose between push and pull to declaratively express their intention and to reduce the overheads due to unnecessary propagation of value changes. With PuPPy, programmers can use signals in Python without any event system and do not have to worry about the type of events and handlers.
('pupush' | 'pupull') <field assignment>
<field assignment> is a normal statement in Python for defining fields in a class:
<field> '=' <expression>
where <expression> is the definition of <field>.
Defining a field dis with pupush
in the
definition of class Point, which represents a point on an
orthogonal coordinate plane:
class Point:
:
x = 0
y = 0
pupush dis = math.sqrt(x ** 2 + y ** 2)
:
The field dis is the distance from the origin. Although here the values of x and y are 0 at the timing of defining dis, the definition of dis is similar to a signal assignment. Whenever the value of x or y is set, the value of dis will be updated automatically.
Similarily, pupull
can be used to define the field
dis. In the case of pupull
, the value of
dis will only be updated when it is really queried
somewhere, i.e. when the value of dis is read in the
evaluation of an expression.