Brandon Rhodes

Brandon Rhodes has spoken at Python conferences from Portland to Warsaw and Budapest. He is interested in how beautiful code patterns can help us tell stories that don’t become an impossible tangle as a code base grows ever larger.

Speaker home page

An Import Loop and a Fiery Reentry

Python & Libraries, Intermediate
8/19/2018 | 11:35 AM-12:20 PM | Fisher

Description

The Skyfield astronomy library generates planet and satellite positions for Python programmers. With it, Brandon was able to schedule a final glimpse of Tiangong-1 hours before it burned up in our planet’s atmosphere. But building a beautiful API always involves compromises, and Brandon will discuss the problem that import loops pose for Python APIs based on method chains.

Abstract

I will start by describing how a library can leverage NumPy and the Jupyter Notebook to avoid reinventing wheels as it brings numerical calculations and powerful visualizations to Python programmers. Using my astronomy library Skyfield as an example, I’ll show how I was able to predict the final few passages of space station Tiangong-1 over my house before its fiery plunge into Earth’s atmosphere in early April.

But Python is not a language that’s in every way perfect. I’ll examine one particular style of API that I used when building Skyfield: the method chain, where objects suggest to the user which operations are possible next by which methods they support. This often requires objects to be able to instantiate other objects — in the case of Skyfield, creating an import loop once the collection of features became rich enough. I’ll look at the options for resolving import loops and what the solution does to the shape of a library like Skyfield.