damccorm opened a new pull request, #41061:
URL: https://github.com/apache/beam/pull/41061
### Description
Optimizes bytecode return-type inference and schema type translation during
pipeline graph construction:
1. **Cache opcode dispatch tables in
`trivial_inference.infer_return_type_func`
(`sdks/python/apache_beam/typehints/trivial_inference.py`):**
- Previously, `infer_return_type_func` imported `opcodes` and
`intrinsic_one_ops` and rebuilt the `simple_ops` dictionary (`{k.upper(): v for
k, v in opcodes.__dict__.items()}`) on every call.
- Hoists `_SIMPLE_OPS` and `_INT_ONE_OPS` to module-level cached tables
initialized once on first use.
2. **Fast-path primitive atomic types in
`SchemaTranslation.typing_to_runner_api`
(`sdks/python/apache_beam/typehints/schemas.py`):**
- Checks `PRIMITIVE_TO_ATOMIC_TYPE` at the top of `typing_to_runner_api`
before inspecting generic origin/dataclass/NamedTuple metadata (**1.26x
faster** schema field translation).
### Testing
- Verified with `pytest
sdks/python/apache_beam/typehints/trivial_inference_test.py
sdks/python/apache_beam/typehints/schemas_test.py`.
--
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]