gh-36308: using itertools.product more often
This replaces some uses of our `cartesian_product_iterator` by
`itertools.product`, for better efficiency.
### :memo: Checklist
- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
URL: https://github.com/sagemath/sage/pull/36308
Reported by: Frédéric Chapoton
Reviewer(s): Marc Mezzarobba
Committer
Release Manager