This makes sure that the lines don't get excessively long, while keepingdiffs that add/remove elements small.
For context: this was extracted from the pytest patchset and extended to more places based on Andres his recommendation.