Skip to content

interval default value; use const() #5

Closed
@dhalbert

Description

@dhalbert

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions