gh-37591: ruff PERF fixes in algebras/
a few changes about using more list comprehensions in `algebras`
plus some pep8, and code details
Note: the `classical_lie_algebras` file has very slow doctest for E7.
### :memo: Checklist
- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
URL: https://github.com/sagemath/sage/pull/37591
Reported by: Frédéric Chapoton
Reviewer(s): Frédéric Chapoton, Giacomo Pope, Travis Scrimshaw