ColtenOuO opened a new pull request, #66369:
URL: https://github.com/apache/airflow/pull/66369
## Summary
In `airflow.cli.commands.config_command.update_config`, the per-change loop
rebuilt four lowercase list comprehensions on every iteration just to do `in`
membership tests against user-provided filter args:
```python
for change in CONFIGS_CHANGES:
...
if update_sections is not None and conf_section not in [s.lower() for s
in update_sections]:
continue
if update_options is not None and full_key not in [opt.lower() for opt
in update_options]:
continue
if conf_section in [s.lower() for s in ignore_sections] or full_key in [
opt.lower() for opt in ignore_options
]:
continue
```
This is O(N·M) (N = number of CONFIGS_CHANGES, M = filter list size), and on
top of the linear scan, every .lower() call is repeated N times for the same
input.
This PR hoists the four filters into pre-built lowercase sets before the
loop, so:
- Membership lookups are O(1).
- Each input is .lower()'d once at setup time, not per iteration.
```python
update_sections_lower = (
{s.lower() for s in update_sections} if update_sections is not None else
None
)
update_options_lower = (
{opt.lower() for opt in update_options} if update_options is not None
else None
)
ignore_sections_lower = {s.lower() for s in ignore_sections}
ignore_options_lower = {opt.lower() for opt in ignore_options}
```
Overall, this chage can make time complexity $O(NM)$ to $O(N+M)$
**Pure refactor — no behavior change.**
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]