Sorry for suggesting this should be a class. I had once misconceived that functions would not pickle nicely, and said the wrong thing when I proposed this helper.