You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is no public method to determine the type of entries in an empty repeated field.
The proto-plus package wraps protobuf messages for many of the Python Google Cloud Client Libraries.
When a repeated field has no entries the proto-plus implementation deep-copies the whole message, adds an entry, and fetches the type of the field from that copy. The deep copying results in a performance hit.
Describe the solution you'd like
An implementation agnostic (works with both C++ and Python implementation types) way to determine type of the elements of an empty repeated field.
Describe alternatives you've considered
To try these examples, pip install googleapis-common-protos to get the built google.api.quota_pb2 proto. Proto file is here.
1. Add an entry to determine the type
This is what we're currently doing but would prefer not to, since we have to copy the whole message first.
In the C++ implementation the code above results in an error:
>>> q.limits._message_descriptor._concrete_class
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'google.protobuf.pyext._message.RepeatedCompositeCo' object has no attribute '_message_descriptor'
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.
This issue is labeled inactive because the last activity was over 90 days ago.
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please reopen it.
This issue was closed and archived because there has been no new activity in the 14 days since the inactive label was added.
What language does this apply to?
Python generated code
Describe the problem you are trying to solve.
There is no public method to determine the type of entries in an empty repeated field.
The
proto-plus
package wraps protobuf messages for many of the Python Google Cloud Client Libraries.When a repeated field has no entries the proto-plus implementation deep-copies the whole message, adds an entry, and fetches the type of the field from that copy. The deep copying results in a performance hit.
Describe the solution you'd like
An implementation agnostic (works with both C++ and Python implementation types) way to determine type of the elements of an empty repeated field.
Describe alternatives you've considered
To try these examples,
pip install googleapis-common-protos
to get the builtgoogle.api.quota_pb2
proto. Proto file is here.1. Add an entry to determine the type
This is what we're currently doing but would prefer not to, since we have to copy the whole message first.
2. Use
_message_descriptor._concrete_class
This only works in the Python implementation and relies on private attributes.
In the C++ implementation the code above results in an error:
Additional context
See googleapis/proto-plus-python#226 for additional context.
The text was updated successfully, but these errors were encountered: