[
https://issues.apache.org/jira/browse/AIRFLOW-3950?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16776897#comment-16776897
]
ASF GitHub Bot commented on AIRFLOW-3950:
-----------------------------------------
XD-DENG commented on pull request #4774: [AIRFLOW-3950] Improve
AirflowSecurityManager.update_admin_perm_view
URL: https://github.com/apache/airflow/pull/4774
### Jira
- https://issues.apache.org/jira/browse/AIRFLOW-3950
### Description
- [x] Here are some details about my PR, including screenshots of any UI
changes:
This PR helps improve `AirflowSecurityManager.update_admin_perm_view` by
- Simplifying the implementation: avoid unnecessary for-loop by using set.
- Improving the performance (especially when there are many DAGs)
In terms of performance improvement, please refer to this simple toy
benchmarking:
```python
def fun1(a, b):
a=set(a)
for i in b:
if i not in a:
a.add(i)
list(a)
def fun2(a, b):
list(set(a) | set(b))
if __name__ == '__main__':
import timeit
print(timeit.timeit("fun1([1,2,3], range(100))", setup="from __main__
import fun1"))
print(timeit.timeit("fun2([1,2,3], range(100))", setup="from __main__
import fun2"))
```
**Result:**
```
12.912254190000112
5.487735479000094
[Finished in 18.5s]
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Improve AirflowSecurityManager.update_admin_perm_view
> -----------------------------------------------------
>
> Key: AIRFLOW-3950
> URL: https://issues.apache.org/jira/browse/AIRFLOW-3950
> Project: Apache Airflow
> Issue Type: Improvement
> Components: webserver
> Reporter: Xiaodong DENG
> Assignee: Xiaodong DENG
> Priority: Minor
>
> The implementation of `AirflowSecurityManager.update_admin_perm_view` can be
> simplified using set.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)