Buy Tickets
Starting from 350€
Support unavailable
Please try again later

Protocol specifications written in Python

by Fredrik Håård for EuroPython 2012

Rapidly updating the requirements and implementation of a machine-to-machine communication protocol is hard in itself, and keeping a protocol specification and documentation up-to-date is always a burden, and sometimes becomes an impossibility.

At Visual Units, when this became a problem with the protocol between the embedded software and the fleet management server, we changed the approach and specified the protocol in Python. This allows us to use the specification directly when generating and parsing messages, as well as making it possible to generate protocol documentation, and source code for our Java (J2ME) client software. We implemented everything from scratch, and found it surprisingly easy to do without documentation and specifications external to The Code.

This talk will focus on lessons learned and pitfalls found during the implementation of this solution, with code examples from our current state of art as well as showcases of some of the mistakes we made and the types of magic used in different iterations - most notably metaclasses and the inspect and imp modules. It will follow the evolution from the first (quite horrible) attempts, to our current implementation. I will also discuss what has been gained by adopting this solution and the tradeoffs that we have made.

The intended audience is developers and designers who work with and design protocols, as well as developers with a general interest in code as specification. This is not a presentation of a framework for use in any application (although code is available), but an in-depth look at how far you can go with custom-built tools.

in on Wednesday 4 July at 14:30 See schedule



  1. Gravatar
    A version of this talk was given @ Software Passion Summit 2012 in Gothenburg.
  2. Gravatar
    A writeup of the contents for this talk at Software Passion Summit is available at

    The talk (if accepted) at EuroPython will have more discussions of implementation details and imp/inspect/exec, and less of background and philosophy. It may also have the next generation, if done by then - or if failed by then as warning example.

New comment

60 minutes

Tagged as

optimization design architecture case-study
Our Sponsors
Python Experts
Personnel development with 360° feedback
SSL Matrix
Wanna sponsor?