[RFC] charpoly behavior; PurePoly vs Poly

28 views
Skip to first unread message

Chris Smith

unread,
Oct 13, 2026, 6:17:52 AMOct 13
to sympy
In 30741 I am trying to address some issues with PurePoly and am running into some API questions.

I think a coherent way to use M.charpoly is like

M.charpoly()             # PurePoly
M.charpoly(x)            # Poly  <-- (*)
M.charpoly().as_poly(x)  # Poly
M.charpoly()(x)          # Expr
___________________
(*) in master charpoly(x) creates a PurePoly with symbol 'x' for display purposes

In the PR, generators are canonical so hashing and equality work as they should. e.g. if `p = PurePoly(x)` and `q = PurePoly(y)` then `hash(p)==hash(q)` and `p==q`.

But master allows `PurePoly(x) == Poly(x)` which seems wrong. The consequence is that if we disallow that equality (like we don't allow `Integer(1)==Float(1)`) then letting `charpoly(x)` produce a `Poly` would break the current contract that `charpoly(x) == charpoly(y)`.

How significant would that sort of change be?

/c
Reply all
Reply to author
Forward
0 new messages