iindyk commented on a change in pull request #12420:
URL: https://github.com/apache/beam/pull/12420#discussion_r468937924
##########
File path: sdks/python/apache_beam/transforms/stats.py
##########
@@ -576,17 +633,34 @@ def _interpolate(self, i_buffers, count, step, offset):
weighted_element = next(sorted_elem)
current = weighted_element[1]
j = 0
- while j < count:
- target = j * step + offset
- j = j + 1
- try:
- while current <= target:
- weighted_element = next(sorted_elem)
- current = current + weighted_element[1]
- except StopIteration:
- pass
- new_elements.append(weighted_element[0])
- return new_elements
+ if self._weighted:
Review comment:
I tried to avoid affecting the performance of the existing codepath, but
after a closer look I think the overhead caused by the if in the loop is
negligible compared to the time taken by the inner loop and append. Merged the
branches.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]