Skip to content

Use isdisjoint instead of not intersection#32616

Merged
potiuk merged 2 commits into
apache:mainfrom
astronomer:use-isdisjoint-for-speed
Jul 15, 2023
Merged

Use isdisjoint instead of not intersection#32616
potiuk merged 2 commits into
apache:mainfrom
astronomer:use-isdisjoint-for-speed

Conversation

@dstandish

Copy link
Copy Markdown
Contributor

it's faster

@dstandish
dstandish requested a review from uranusjr July 14, 2023 19:13
Comment thread airflow/www/utils.py
return False

if not user_roles.intersection(set(self.roles)):
if user_roles.isdisjoint(self.roles):

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

note on removal of set: roles doesn't need to be set to pass to isdisjoint

@potiuk

potiuk commented Jul 15, 2023

Copy link
Copy Markdown
Member

Nice. Indeed faster as it can short-circuit when match is found

@potiuk
potiuk merged commit 51052bb into apache:main Jul 15, 2023
@uranusjr
uranusjr deleted the use-isdisjoint-for-speed branch July 16, 2023 02:20
@ephraimbuddy ephraimbuddy added the type:improvement Changelog: Improvements label Aug 2, 2023
@ephraimbuddy ephraimbuddy added this to the Airflow 2.7.0 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:improvement Changelog: Improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants