gemini-code-assist[bot] commented on code in PR #39132:
URL: https://github.com/apache/beam/pull/39132#discussion_r3484708618


##########
sdks/python/apache_beam/transforms/stats_test.py:
##########
@@ -264,6 +264,10 @@ def _approx_quantile_generator(size, num_of_quantiles, 
absoluteError):
     quantiles.append(size - 1)
     return quantiles
 
+  @staticmethod
+  def _sum_and_second(x):
+    return (sum(x), x[1])

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   Since `x` is a 2-tuple, using `x[0] + x[1]` is more explicit and faster than 
the built-in `sum(x)`, which incurs overhead by iterating over the tuple. This 
is a useful optimization for key functions in `ApproximateQuantiles` as they 
are executed for every element in the collection.
   
   ```suggestion
     @staticmethod
     def _sum_and_second(x):
       return (x[0] + x[1], x[1])
   ```



-- 
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