XD-DENG opened a new 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]


With regards,
Apache Git Services

Reply via email to