A Lightweight Push-Pull Mechanism for Implicitly Using Signals in Imperative Programming

YungYu Zhuang, Ph.D.

Programming & Software Lab, National Central University


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.


A prototype implementation of PuPPy extension on GitHub
Examples of using pupush and pupull
Examples of the transformation performed by PuPPy
Examples of implementing and using combinators
Preliminary microbenchmarks for measuring the performance overheads



  1. YungYu Zhuang and Shigeru Chiba.
    Expanding Event Systems to Support Signals by Enabling the Automation of Handler Bindings.
    Journal of Information Processing Vol.24 No.4, IPSJ, pp.620-634, July 2016.
    Special Issue of Applications and the Internet in Conjunction with Main Topics of COMPSAC 2015.
  2. YungYu Zhuang and Shigeru Chiba.
    Enabling the Automation of Handler Bindings in Event-Driven Programming.
    In proceedings of the 39th IEEE annual international Computers, Software & Applications Conference (COMPSAC'15),
    pp.137-146, July 2015.