Skip to content

Conversation

miss-islington
Copy link
Contributor

(cherry picked from commit 0e28a3a)

Co-authored-by: Raymond Hettinger rhettinger@users.noreply.github.com

(cherry picked from commit 0e28a3a)

Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
@miss-islington
Copy link
Contributor Author

@rhettinger: Status check is done, and it's a failure ❌ .

@rhettinger rhettinger merged commit 21c46f3 into python:3.11 Aug 21, 2022
@miss-islington miss-islington deleted the backport-0e28a3a-3.11 branch August 21, 2022 14:47
@miss-islington
Copy link
Contributor Author

Status check is done, and it's a success ✅ .

@mdickinson
Copy link
Member

mdickinson commented Aug 22, 2022

@rhettinger It may be worth adding a caveat that this approach should only be used for small inputs. While it's an interesting demonstration of pieces of itertools, it's also inefficient (exponential time) for large inputs, compared to the obvious multiply-the-linear-terms quadratic-time algorithm:

def polynomial_from_roots(roots):
    poly = [1]
    for root in roots:
        poly = [a + b for a, b in zip([0] + [c * -root for c in poly], poly + [0])]
    return poly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip issue skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants