Version: 0.2
This module offers three undo stack implementations. Each has different tradeoffs, and may be better suited to a given situation than the others.
- define a class (or named tuple) for each operation, with "do" and "undo" methods
- hand instances of these classes to the stack object
- doesn't require any handle on the object(s) being modified by the operations
- up to the user to ensure reversibility, which in some cases can be quite difficult
- least memory and runtime overhead for operations
- define a callable object for each operation
- hand instances of these objects to the stack object
- requires a handle on or snapshot of the initial state of the object(s) being modified by the operations; operations must accept this handle as a parameter when called
- higher overhead, especially for
undo
operation
- requires handles on or snapshots of incremental states of the object(s) being modified. These snapshots are triggered explicitly by the user, and may be taken as frequently or rarely as desired
- can involve significant memory overhead in the worst case
undone
works under Python 2.7 and Python 3.3+.
To install:
$ git clone http://github.com/gfetterman/undone.git
$ cd undone
$ pip install .
# to run the tests
$ pytest -v
(Coming soon.)