You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "ColtenOuO (via GitHub)" <gi...@apache.org> on 2026/05/04 16:30:40 UTC
[PR] Avoid rebuilding option filter sets per iteration in update_config CLI ( O(N*M) to O(N+M) ) [airflow]
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Avoid rebuilding option filter sets per iteration in update_config CLI ( O(N*M) to O(N+M) ) [airflow]
Posted by "ColtenOuO (via GitHub)" <gi...@apache.org>.
ColtenOuO commented on PR #66369:
URL: https://github.com/apache/airflow/pull/66369#issuecomment-4373103283
Force-pushed: `ruff format` flagged a couple of multi-line parenthesised expressions that should be on a single line. The functional change is unchanged. CI should be green now.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Avoid rebuilding option filter sets per iteration in update_config CLI ( O(N*M) to O(N+M) ) [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk merged PR #66369:
URL: https://github.com/apache/airflow/pull/66369
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org