Skip to content
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

implement support for condensed bit masks #382

Merged
merged 3 commits into from
Jan 22, 2025

Conversation

andlaus
Copy link
Member

@andlaus andlaus commented Jan 21, 2025

IMO this is a somewhat exotic feature, but since it is in the spec there probably is somebody out there who uses it...

Andreas Lauser <andreas.lauser@mercedes-benz.com>, on behalf of MBition GmbH.
Provider Information

IMO this is a somewhat exotic feature...

Signed-off-by: Andreas Lauser <andreas.lauser@mercedes-benz.com>
Signed-off-by: Michael Hahn <michael.hahn@mbition.io>
@andlaus andlaus requested a review from kayoub5 January 21, 2025 14:53
Signed-off-by: Andreas Lauser <andreas.lauser@mercedes-benz.com>

# TODO: this is pretty slow. replace it by
# `self.bit_mask.bit_count()` once we require python >=
# 3.10.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are not that far away from 3.9 end of life, you may drop it now

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I promised myself to support python 3.8 until ubuntu 20.04 is EOL. Fortunately, this is not too far off anymore (April), then we can do the same for Ubuntu 22.04 / python 3.10. I've added an item to the TODO list, though: #286 . (That said, I suspect that the performance impact of converting the integer to a string and counting the one characters is lower than the interpreter overhead of doing two instead of one function calls. For compiled languages this is a completely different story...)

this basically means using `isinstance(*, SupportsBytes)` instead of
`isinstance(*, bytes)`. Interestingly enough, `isinstance(bytearray(),
SupportsBytes)` is `False`, so we have to explicitly check for
`bytearray` as well.

thanks to [at]kayoub5 for the catch!

Signed-off-by: Andreas Lauser <andreas.lauser@mercedes-benz.com>
@andlaus andlaus force-pushed the condensed_bitmasks branch from e4d7724 to 5b2b0d9 Compare January 22, 2025 09:44
@andlaus andlaus merged commit 90dc288 into mercedes-benz:main Jan 22, 2025
7 checks passed
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

Successfully merging this pull request may close these issues.

2 participants