damccorm opened a new pull request, #41111:
URL: https://github.com/apache/beam/pull/41111

   ### Description
   
   Optimizes `WindowedValue.__hash__` and 
`HomogeneousWindowedBatch.from_windowed_values` in 
`sdks/python/apache_beam/utils/windowed_value.py`:
   
   1. **`HomogeneousWindowedBatch.from_windowed_values`:**
      - Previously, `from_windowed_values` allocated a transient 
`WindowedValue` instance via `wv.with_value(None)` for every input element 
solely to use as a dictionary key in `grouped`.
      - Keying `grouped` directly on the lightweight `(wv.timestamp_micros, 
windows, wv.pane_info)` tuple and constructing the batch `WindowedValue` once 
per unique window group avoids a `WindowedValue` allocation on every element 
(**3.39x faster** batch grouping).
   2. **`WindowedValue.__hash__`:**
      - Avoids allocating a new `tuple(self.windows)` copy when `self.windows` 
is already a `tuple`.
   
   ### Testing
   - Verified with `pytest 
sdks/python/apache_beam/utils/windowed_value_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]

Reply via email to