Probably there should be a flag that, if set, preserves operator order. This would only be used if the input
expression is a string, as when the input is a sympy expression, the constituent symbols will already have any
commutation relations defined
Just to make a note here: it seems like a good option to specify in the docstring that we preserve order of generators only between them, not between other symbols in input expression.
For example (new behaviour):
>>> x, y, A = sympy.symbols('x y A', commutative=False)>>> expr = x**2 * A * y + y * x**2>>> monomials(expr, x, y){x**2 * y: A, y * x**2: 1}