Skip to content

Conversation

@hussein-awala
Copy link
Member


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in newsfragments.

@potiuk
Copy link
Member

potiuk commented Aug 26, 2023

Hmmm. Not so sure about this one . I actually like better the dict variant. What's the reason you want to change it @hussein-awala ? (Not strongly opposing - but wanted to know the reasoning).

@Lee-W
Copy link
Member

Lee-W commented Aug 26, 2023

Hmmm. Not so sure about this one . I actually like better the dict variant. What's the reason you want to change it @hussein-awala ? (Not strongly opposing - but wanted to know the reasoning).

AFAIK, {} seems to perform a bit (not noticeable) better than dict(). I like literal dict a bit better (more readable to me). Especially in a place like here.

@potiuk
Copy link
Member

potiuk commented Aug 26, 2023

Yeah. Performance is noticeably faster. Fine for me

From https://stackoverflow.com/questions/6610606/is-there-a-difference-between-using-a-dict-literal-and-a-dict-constructor

Literal is much faster, since it uses optimized BUILD_MAP and STORE_MAP opcodes rather than generic CALL_FUNCTION:

python2.7 -m timeit "d = dict(a=1, b=2, c=3, d=4, e=5)"
1000000 loops, best of 3: 0.958 usec per loop

python2.7 -m timeit "d = {'a':1, 'b':2, 'c':3, 'd':4, 'e':5}"
1000000 loops, best of 3: 0.479 usec per loop

python3.2 -m timeit "d = dict(a=1, b=2, c=3, d=4, e=5)"
1000000 loops, best of 3: 0.975 usec per loop

python3.2 -m timeit "d = {'a':1, 'b':2, 'c':3, 'd':4, 'e':5}"
1000000 loops, best of 3: 0.409 usec per loop

@potiuk potiuk merged commit 1e81ed1 into apache:main Aug 26, 2023
@ephraimbuddy ephraimbuddy added this to the Airflow 2.7.2 milestone Oct 3, 2023
@ephraimbuddy ephraimbuddy added the type:misc/internal Changelog: Misc changes that should appear in change log label Oct 3, 2023
ephraimbuddy pushed a commit that referenced this pull request Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:API Airflow's REST/HTTP API area:CLI area:logging area:Scheduler including HA (high availability) scheduler area:serialization area:webserver Webserver related Issues type:misc/internal Changelog: Misc changes that should appear in change log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants