<div id="comment:0"></div> cherry-picked from #32432 Depends on #32637 Depends on #32665 CC: @kliem Component: **refactoring** Author: **Matthias Koeppe** Branch/Commit: **[`8679256`](https://github.com/sagemath/sagetrac-mirror/commit/86792565c64268503894499a5a0ffb14470aff8c)** Reviewer: **Jonathan Kliem** _Issue created by migration from https://trac.sagemath.org/ticket/32725_