Skip to content
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

Tween fix #23

Merged
merged 2 commits into from
Nov 4, 2019
Merged

Tween fix #23

merged 2 commits into from
Nov 4, 2019

Conversation

rowlap
Copy link
Contributor

@rowlap rowlap commented Nov 3, 2019

Resolves issue #22, then optimize away repeated operations in the inner loop.

Take a copy instead of a reference to _values, so that start isn't changing
through the loop.
* Move the floating point division out of the inner loop
* Use map() / list comprehensions where possible, in preference to nested loop
* Don't call show() explicitly if _set() already did it
* Regression test (not committed) shows identical _values being written at each step
@Gadgetoid Gadgetoid merged commit b8c9956 into pimoroni:master Nov 4, 2019
@Gadgetoid
Copy link
Member

Thank you for taking the time to PR this! I had to make a couple of fixes to maintain support for Python 2.7 (groan) but otherwise it works a treat.

@rowlap rowlap deleted the tween-fix branch November 4, 2019 19:27
@rowlap
Copy link
Contributor Author

rowlap commented Nov 4, 2019

Thanks for the tweaks; I did consider python2.7 (hence __future__ division) but didn't actually run the code under that version. The round() to float is annoying, but I can't see a better alternative without separate code paths for py2/3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants