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 08:45:31 UTC
[PR] Avoid rebuilding callback field list on every serialization loop [airflow]
ColtenOuO opened a new pull request, #66343:
URL: https://github.com/apache/airflow/pull/66343
## Summary
In `airflow-core/src/airflow/serialization/serialized_objects.py`, the same set of five callback type names (`execute, failure, success, retry, skipped`) was duplicated inline in four places — three of them as `[f"on_{x}_callback" for x in (...)]` list comprehensions used for `in` membership tests inside loops over operator/DAG fields.
This PR hoists them to three module-level constants:
```python
_CALLBACK_TYPES = ("execute", "failure", "success", "retry", "skipped")
_OPERATOR_CALLBACK_FIELDS = frozenset(f"on_{x}_callback" for x in _CALLBACK_TYPES)
_HAS_CALLBACK_FIELDS = frozenset(f"has_on_{x}_callback" for x in _CALLBACK_TYPES)
```
and replaces the four inline duplicates accordingly.
## Why
- Membership checks become O(1) instead of O(n) over a freshly-built list.
- The 5-element list and its f-string formatting were rebuilt on every iteration of the surrounding for k, v in ... loops; now they're built once at import.
- Single source of truth for the callback type names.
**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 callback field list on every serialization loop [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk merged PR #66343:
URL: https://github.com/apache/airflow/pull/66343
--
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