🏡 Open source home automation that puts local control and privacy first.
Find a file
Paul Ganssle efa5c59559
Replace hand-rolled binary search with bisect_left (#50410)
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.
2021-05-11 08:18:20 -07:00
.devcontainer Call setup during devcontainer create (#46224) 2021-02-08 16:16:40 +01:00
.github Fix compare syntax (#50451) 2021-05-11 13:23:56 +02:00
.vscode Allow debugging of integration dependancies (#49211) 2021-04-14 19:26:37 +02:00
docs Remove Travis CI config (#44443) 2020-12-22 13:49:42 +01:00
homeassistant Replace hand-rolled binary search with bisect_left (#50410) 2021-05-11 08:18:20 -07:00
machine Remove DHT from Raspberry Pi machine builds (#49829) 2021-04-28 22:43:40 +02:00
pylint/plugins Have pylint warn when user visible log messages do not start with capital letter or end with a period (#48064) 2021-03-19 09:26:36 -05:00
rootfs Update base image to version 2021.04.3 (#49817) 2021-04-28 18:03:21 +02:00
script Improve type annotations for GIOS integration (#50454) 2021-05-11 07:57:24 -07:00
tests Improve type annotations for GIOS integration (#50454) 2021-05-11 07:57:24 -07:00
.coveragerc Clean somfy config flow tests (#50461) 2021-05-11 16:19:07 +02:00
.dockerignore Integrate dockerbuild (#33168) 2020-03-23 00:39:37 +01:00
.gitattributes highlight Dockerfile.dev as Dockerfile in github ui (#36933) 2020-06-22 14:45:57 +02:00
.gitignore Fix too agressive .gitignore (#41677) 2020-10-12 16:48:42 +02:00
.hadolint.yaml Add hadolint to CI (#34758) 2020-04-27 12:09:31 +02:00
.ignore Include .ignore file for search utilities (#5290) 2017-01-16 22:52:53 -08:00
.pre-commit-config.yaml Upgrade pyupgrade to v2.14.0 (#50059) 2021-05-05 09:28:47 +02:00
.prettierignore Rename translations dir for integrations (#34494) 2020-04-21 16:11:05 -07:00
.readthedocs.yml Drop remaining Python < 3.8 support (#44743) 2021-01-04 11:47:29 +01:00
.strict-typing Improve type annotations for GIOS integration (#50454) 2021-05-11 07:57:24 -07:00
.yamllint Add yamllint (in pre-commit and CI) (#33676) 2020-04-05 10:33:45 +02:00
azure-pipelines-ci.yml Revert "Update azure-pipelines-ci.yml to enable black mode in isort" (#45390) 2021-01-21 11:01:22 +01:00
azure-pipelines-translation.yml Drop remaining Python < 3.8 support (#44743) 2021-01-04 11:47:29 +01:00
build.json Update base image to version 2021.04.3 (#49817) 2021-04-28 18:03:21 +02:00
CLA.md Update LICENSE.md and CLA.md to reflect the new Apache 2.0 license 2017-01-28 12:12:34 -08:00
CODE_OF_CONDUCT.md Update Code of Conduct to 2.0 (#36142) 2020-05-25 19:40:40 -04:00
codecov.yml Update Codecov.io configuration (#33783) 2020-04-07 09:01:01 -07:00
CODEOWNERS Add syncthing integration (#38331) 2021-05-08 19:12:14 +02:00
CONTRIBUTING.md Use core GitHub URL in contributing guidelines (#41083) 2020-10-02 20:42:33 +02:00
Dockerfile Increase timeout to avoid killing the core during shutdown (#45029) 2021-01-11 11:24:02 +01:00
Dockerfile.dev Install requirements.txt while building dev Dockerfile (#48268) 2021-03-23 14:04:15 -07:00
LICENSE.md Update license to official GitHub template (#16470) 2018-09-07 10:11:51 +02:00
MANIFEST.in Consolidate frontend (#9915) 2017-10-24 19:36:27 -07:00
mypy.ini Improve type annotations for GIOS integration (#50454) 2021-05-11 07:57:24 -07:00
pyproject.toml Update pylint to 2.8.0 (#49637) 2021-04-24 14:39:24 -10:00
README.rst Update README.rst to avoid redirects (#44519) 2020-12-26 10:05:41 +01:00
requirements.txt Use zoneinfo instead of dateutil (#50387) 2021-05-10 08:32:29 -07:00
requirements_all.txt pyTibber revert (#50462) 2021-05-11 16:14:32 +02:00
requirements_docs.txt Refactor API documentation (#33217) 2020-03-25 13:21:04 -07:00
requirements_test.txt Upgrade requests-mock to 1.9.2 (#50377) 2021-05-09 16:30:03 -05:00
requirements_test_all.txt pyTibber revert (#50462) 2021-05-11 16:14:32 +02:00
requirements_test_pre_commit.txt Upgrade pyupgrade to v2.14.0 (#50059) 2021-05-05 09:28:47 +02:00
setup.cfg Don't ignore mypy errors by default (#49270) 2021-04-26 14:23:21 +02:00
setup.py Use zoneinfo instead of dateutil (#50387) 2021-05-10 08:32:29 -07:00
tox.ini Fix local mypy workflow (#48433) 2021-03-30 17:18:29 +02:00

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/