The two kinds of gaps appear to have slightly different explanations. “We find evidence that gender disparities by political affiliation are largely driven by violent offenses and drug offenses,” the study said. “We also find that racial disparities by political affiliation are largely driven by drug offenses.”

The authors of the study sounded a note of caution. “The precise reasons why these disparities by political affiliation exist remain unknown and we caution that our results cannot speak to whether the sentences imposed by Republican- or Democratic-appointed judges are warranted or ‘right,’” the authors wrote. “Our results, however, do suggest that Republican- and Democratic-appointed judges treat defendants differently on the basis of their race and gender given that we observe robust disparities despite the random assignment of cases to judges within the same court.”

The study is studded with fascinating tidbits. Black judges treat male and female offenders more equally than white judges do. Black judges appointed by Republicans treat black offenders more leniently than do other Republican appointees.

More experienced judges are less apt to treat black and female defendants differently. Judges in states with higher levels of racism, as measured by popular support for laws against interracial marriage, are more likely to treat black defendants more harshly than white ones.

The Trump administration has been quite successful in stocking the federal bench with its appointees, and by some estimates the share of Republican appointees on the federal district courts could rise to 50 percent in 2020, from 34 percent in early 2017.

The study said these trends were likely to widen the sentencing gaps.

“Our estimates suggest that a 10 percentage point increase in the share of Republican-appointed judges in each court would increase the racial sentencing gap by approximately 5 percent and the gender sentencing gap by roughly 2 percent,” the authors wrote. “During an average four-year term, a Republican president has the potential to alter the partisan composition of the district courts by over 15 percentage points, potentially increasing the racial and gender sentencing gap by 7.5 and 3 percent, respectively.”

There are a couple of reasons to question that prediction. The Trump administration has been more energetic in appointing appeals court judges than trial judges. And in recent years many conservatives have started to shift positions on sentencing policy. The very scope of the study, which considered sentences imposed from 1999 to 2015, could mask trends in the later years.