Monday 5:10 p.m.–5:40 p.m.
Building Protocol Libraries The Right Way
- Audience level:
- Python Libraries
One of the great strengths of the Python ecosystem is the enormous collection of powerful, flexible libraries. However, these libraries tend to suffer from one extremely common design flaw that mean that the work done is not easily re-usable or transferable. In this talk, we talk about how to build libraries that can be used as widely as possible, through the lens of the Python Hyper HTTP project.
One of the great strengths of Python is the incredible richness of its libraries. The standard library is already fairly good, and when you take into account the third-party ecosystem, Python’s is up there with the best in the world. Despite that, however, a great deal of effort has been wasted to get to this place. Consider Python’s HTTP ecosystem, which has many fantastic libraries. Unfortunately, there’s a stunning lack of code re-use across them: different HTTP libraries often have essentially no common code at all, despite doing extremely similar jobs. Sometimes this occurs in projects that are intended to be almost identical, such as requests and treq. This talk proposes that the primary reason this occurs is because each library contains its own I/O layer. It explores exactly how this problem comes about, and discusses an alternative approach to library design that vastly has many benefits over the standard approach. It uses as its core examples many projects the author has worked on, including the only library he has written that he believes gets this right. It also talks about where this approach is used outside of Python to great effect to provide extra weight for the example.