Andrushika opened a new pull request, #77192: URL: https://github.com/apache/airflow/pull/77192
## Why Every process that imports `DAG`, `task` or `BaseOperator` loads `libcst`. That adds about 70ms to each start, and only a few task decorators use it. 1. `bases/operator.py` imports `definitions/_internal/decorators.py`. 2. That module imports `libcst` at the top. 3. Only `remove_task_decorator` in that module needs `libcst`. `remove_task_decorator` runs when a decorator such as `@task.virtualenv` or `@task.docker` extracts the function source. ## What Import `libcst` inside `remove_task_decorator`. Tasks with those decorators load `libcst` on their first run. A `@task.stub` Dag still loads it at parse time. A new test checks that `from airflow.sdk import DAG, task` does not load `libcst`. ## Benchmark Fresh process per run in the `apache/airflow:3.4.0-python3.12` image with the sources of this branch mounted, median of 15 runs, main → this PR: - `from airflow.sdk import DAG, task`: 676ms → 593ms - `DagBag` load of one Dag: 851ms → 784ms - import supervisor and task runner: 725ms → 659ms --- ##### Was generative AI tooling used to co-author this PR? - [X] Yes (please specify the tool below) Generated-by: Claude Code (Fable 5.2) following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions) -- 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]
