🏡 Open source home automation that puts local control and privacy first.
The `bisect` module exposes a `bisect_left` function which does basically what the bulk of `_lower_bound` does. From my tests, it is slightly faster (~5%) in the probably common ideal case where `arr` is short. In the worst case scenario, `bisect.bisect_left` is *much* faster. ``` >>> arr = list(range(60)) >>> cmp = 59 >>> %timeit _lower_bound(arr, cmp) 736 ns ± 6.24 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each) >>> %timeit bisect_lower_bound(arr, cmp) 290 ns ± 7.77 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each) ``` I doubt this is a huge bottleneck or anything, but I think it's a bit more readable, and it's more efficient, so it seems like it's mostly a win. This commit *will* add a new unconditional import for `bisect` when importing `util.dt`, and `bisect` is not currently imported for any of the standard library modules. It is possible to make this conditional by placing `import bisect` in the _lower_bound function, or in the function it's nested in. |
||
---|---|---|
.devcontainer | ||
.github | ||
.vscode | ||
docs | ||
homeassistant | ||
machine | ||
pylint/plugins | ||
rootfs | ||
script | ||
tests | ||
.coveragerc | ||
.dockerignore | ||
.gitattributes | ||
.gitignore | ||
.hadolint.yaml | ||
.ignore | ||
.pre-commit-config.yaml | ||
.prettierignore | ||
.readthedocs.yml | ||
.strict-typing | ||
.yamllint | ||
azure-pipelines-ci.yml | ||
azure-pipelines-translation.yml | ||
build.json | ||
CLA.md | ||
CODE_OF_CONDUCT.md | ||
codecov.yml | ||
CODEOWNERS | ||
CONTRIBUTING.md | ||
Dockerfile | ||
Dockerfile.dev | ||
LICENSE.md | ||
MANIFEST.in | ||
mypy.ini | ||
pyproject.toml | ||
README.rst | ||
requirements.txt | ||
requirements_all.txt | ||
requirements_docs.txt | ||
requirements_test.txt | ||
requirements_test_all.txt | ||
requirements_test_pre_commit.txt | ||
setup.cfg | ||
setup.py | ||
tox.ini |
Home Assistant |Chat Status| ================================================================================= Open source home automation that puts local control and privacy first. Powered by a worldwide community of tinkerers and DIY enthusiasts. Perfect to run on a Raspberry Pi or a local server. Check out `home-assistant.io <https://home-assistant.io>`__ for `a demo <https://home-assistant.io/demo/>`__, `installation instructions <https://home-assistant.io/getting-started/>`__, `tutorials <https://home-assistant.io/getting-started/automation/>`__ and `documentation <https://home-assistant.io/docs/>`__. |screenshot-states| Featured integrations --------------------- |screenshot-components| The system is built using a modular approach so support for other devices or actions can be implemented easily. See also the `section on architecture <https://developers.home-assistant.io/docs/architecture_index/>`__ and the `section on creating your own components <https://developers.home-assistant.io/docs/creating_component_index/>`__. If you run into issues while using Home Assistant or during development of a component, check the `Home Assistant help section <https://home-assistant.io/help/>`__ of our website for further help and information. .. |Chat Status| image:: https://img.shields.io/discord/330944238910963714.svg :target: https://discord.gg/c5DvZ4e .. |screenshot-states| image:: https://raw.github.com/home-assistant/home-assistant/master/docs/screenshots.png :target: https://home-assistant.io/demo/ .. |screenshot-components| image:: https://raw.github.com/home-assistant/home-assistant/dev/docs/screenshot-components.png :target: https://home-assistant.io/integrations/