gemini-code-assist[bot] commented on code in PR #39213:
URL: https://github.com/apache/beam/pull/39213#discussion_r3536982443
##########
sdks/python/apache_beam/io/components/rate_limiter.py:
##########
@@ -171,10 +166,11 @@ def allow(self, hits_added: int = 1) -> bool:
for d in self.descriptors:
entries = []
for k, v in d.items():
- entries.append(RateLimitDescriptorEntry(key=k, value=v))
- proto_descriptors.append(RateLimitDescriptor(entries=entries))
+ entries.append(rate_limit_pb2.RateLimitDescriptor.Entry(key=k,
value=v))
+ proto_descriptors.append(
+ rate_limit_pb2.RateLimitDescriptor(entries=entries))
Review Comment:

Using `add()` directly on the repeated composite field is more idiomatic in
Python protobuf and avoids creating intermediate lists and temporary message
objects.
```python
for d in self.descriptors:
descriptor = rate_limit_pb2.RateLimitDescriptor()
for k, v in d.items():
descriptor.entries.add(key=k, value=v)
proto_descriptors.append(descriptor)
```
--
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]