PyConGenericFunctions


Writing Efficient Rule-Driven Software in Python

Author
Phillip J. Eby
Contact-Info
mailto:pje@telecommunity.com
Requested-Timeslot
45 minutes

Summary

In the design of applications, rules are everywhere: business rules, game rules, routing rules, "expert systems", code and query optimizers, and rule-based "agents" and triggers. But to implement rules, they have to be converted into code -- usually in the form of decision trees that become increasingly difficult to maintain as the number of rules grows. Recent developments in computer science, however, make it possible to automatically convert rules into decision trees that are guaranteed to be correct and efficient, even for large numbers of rules, without using a specialized logic or rule language like Prolog or Lisp. This presentation will give an overview of how to implement rule-driven systems directly in Python, using Python itself as the language for specifying rules, with faster development and execution times than would be obtained by hand-coding if-then trees. Examples will be based on the predicate dispatch implementation included in the latest version of the PyProtocols package.

Part 1: The Rules We Live By

Part 2: Implementing Rules with PyProtocols' dispatch package

Part 3: Past, Present, and Future

(Bonus material, for use if above runs short and there are no questions)