Skip to content

interval default value; use const() #5

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

Closed
dhalbert opened this issue Jan 8, 2019 · 1 comment
Closed

interval default value; use const() #5

dhalbert opened this issue Jan 8, 2019 · 1 comment

Comments

@dhalbert
Copy link
Contributor

dhalbert commented Jan 8, 2019

Hi @dastels, didn't have a chance to review this before today. Just a couple of comments;

  1. Why check for interval is None in the constructor if it already has a default value? I think self._interval = interval would be sufficient.

  2. Do

from micropython import const
...
_DEBOUNCED_STATE = const(0x01)
_UNSTABLE_STATE = const(0x02)
_CHANGED_STATE = const(0x04)

This will, at compile time, substitute the integer values for the names. This speeds up the code and makes it smaller. The underscored names will actually disappear from the compiled code because they aren't exeternally available. See
http://docs.micropython.org/en/latest/reference/speed_python.html#the-const-declaration
and
http://docs.micropython.org/en/latest/library/micropython.html?highlight=const#micropython.const

@dhalbert
Copy link
Contributor Author

dhalbert commented Jan 8, 2019

Fixed by #6.

@dhalbert dhalbert closed this as completed Jan 8, 2019
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

No branches or pull requests

1 participant