github-actions[bot] commented on code in PR #41160:
URL: https://github.com/apache/beam/pull/41160#discussion_r4528773078
##########
sdks/python/apache_beam/runners/common.py:
##########
@@ -1021,17 +1021,18 @@ def _invoke_process_per_window(
'instead, got \'%s\'.') % (windowed_value.value, ))
for i, p in self.placeholders_for_process:
- if core.DoFn.ElementParam == p:
+ if p is core.DoFn.ElementParam or core.DoFn.ElementParam == p:
Review Comment:
**🟡 Medium**: Using `p is core.DoFn.<Param> or core.DoFn.<Param> == p` in an
`if`/`elif` chain only short-circuits `__eq__` on the single branch that
matches `p`. Whenever `p` is a parameter after `ElementParam` (e.g.,
`WindowParam`, `TimestampParam`, `PaneInfoParam`, `StateParam`, `TimerParam`),
`p is ...` evaluates to `False` on every preceding branch and `or` still falls
through to evaluate `core.DoFn.<OtherParam> == p` (invoking `_DoFnParam.__eq__`
on each preceding branch).
Additionally, when a `DoFn` is unpickled on a worker, `d` in
`method.defaults` is a new `_DoFnParam` instance, and `_get_arg_placeholders`
(lines 727–753) currently stores `ArgPlaceholder(d)` rather than the singleton
`ArgPlaceholder(core.DoFn.<Param>)`, which causes `p is core.DoFn.<Param>` to
be `False` even on the matching branch.
If `_get_arg_placeholders` canonicalizes `d` to the `core.DoFn.<Param>`
singletons once at initialization time (e.g.,
`ArgPlaceholder(core.DoFn.WindowParam)`), then both
`_invoke_process_per_window` and `_invoke_process_batch_per_window` can use `p
is core.DoFn.<Param>` directly without the `or ... == p` fallback.
--
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]