Bluetooth-Devices / dbus-fast

A faster version of dbus-next
MIT License
35 stars 8 forks source link

feat!: don't import backends by default #243

Closed dlech closed 12 months ago

dlech commented 12 months ago

Since the top-level __init__.py is always imported when any subpackage is imported, this caused both backends (glib and aio) to always be imported. This is not desirable, since it means that the glib backend will always be imported, even if the user only wants to use the aio. This wastes resources and in some cases can even cause a crash.

Fixes: https://github.com/Bluetooth-Devices/dbus-fast/issues/242

codecov[bot] commented 12 months ago

Codecov Report

Patch coverage: 50.00% and project coverage change: +0.03% :tada:

Comparison is base (14f52f2) 82.81% compared to head (d2a0104) 82.84%. Report is 1 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #243 +/- ## ========================================== + Coverage 82.81% 82.84% +0.03% ========================================== Files 28 28 Lines 3259 3259 Branches 674 674 ========================================== + Hits 2699 2700 +1 + Misses 343 342 -1 Partials 217 217 ``` | [Files Changed](https://app.codecov.io/gh/Bluetooth-Devices/dbus-fast/pull/243?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Bluetooth-Devices) | Coverage Δ | | |---|---|---| | [src/dbus\_fast/\_\_version\_\_.py](https://app.codecov.io/gh/Bluetooth-Devices/dbus-fast/pull/243?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Bluetooth-Devices#diff-c3JjL2RidXNfZmFzdC9fX3ZlcnNpb25fXy5weQ==) | `0.00% <0.00%> (ø)` | | | [src/dbus\_fast/\_\_init\_\_.py](https://app.codecov.io/gh/Bluetooth-Devices/dbus-fast/pull/243?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Bluetooth-Devices#diff-c3JjL2RidXNfZmFzdC9fX2luaXRfXy5weQ==) | `100.00% <100.00%> (ø)` | | ... and [1 file with indirect coverage changes](https://app.codecov.io/gh/Bluetooth-Devices/dbus-fast/pull/243/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Bluetooth-Devices)

:umbrella: View full report in Codecov by Sentry.

:loudspeaker: Have feedback on the report? Share it here.

dlech commented 12 months ago

Technically, this is an API breaking change, but I think the only thing it would break is:

import dbus_fast

dbus_fast.aio.something

or

from dbus_fast import *

aio.something

which I hope would be quite rare.

bdraco commented 12 months ago

We should probably mark it as a breaking change.

Testing this now

bdraco commented 12 months ago

Pushed to all my production. Nothing broke. Let's hope thats the case for everyone else

bdraco commented 12 months ago

Thanks @dlech

bdraco commented 12 months ago

Everything was ok with the dep bump except bleak

bleak 0.21.0 depends on dbus-fast<2.0.0 and >=1.83.0; platform_system == "Linux"