Skip to content

Tweak polynomial itertool recipes #102880

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 21, 2023
Merged

Conversation

rhettinger
Copy link
Contributor

  • Applying reversed to the range object instead of coefficients reduces the requirements for the coefficients. Now, only __iter__ and __len__ are needed. Formerly, either __getitem__ or __reversed__ were needed as well.

  • Express the polynomial_from_roots recipe in terms of convolve() this better matches the way it would be done by hand. Also, it nicely demonstrates iterator nesting. The previous version was meant to show-off an application of combinations but that was already demonstrated in the powerset() recipe.

@bedevere-bot bedevere-bot added docs Documentation in the Doc dir skip news awaiting core review labels Mar 21, 2023
@rhettinger rhettinger merged commit 0214c7a into python:main Mar 21, 2023
Fidget-Spinner pushed a commit to Fidget-Spinner/cpython that referenced this pull request Mar 27, 2023
@pochmann
Copy link
Contributor

pochmann commented Apr 9, 2023

  • Express the polynomial_from_roots recipe in terms of convolve()

Ah, I showed you the right algorithm but the wrong implementation. Beautifully done with convolve.

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.

3 participants