Skip to content

Commit

Permalink
fix(perf): improve performance unmarshalling entities from protobuf2 (#…
Browse files Browse the repository at this point in the history
…175)

Uses direct access of pb2 object when iterating over Entity.properties. This reduces the time required to hydrate query results by 50%
  • Loading branch information
craiglabenz committed May 25, 2021
1 parent 57b0fe6 commit 0e5b718
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions google/cloud/datastore/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def entity_from_protobuf(pb):
entity_meanings = {}
exclude_from_indexes = []

for prop_name, value_pb in _property_tuples(proto_pb):
for prop_name, value_pb in _property_tuples(proto_pb._pb):
value = _get_value_from_value_pb(value_pb)
entity_props[prop_name] = value

Expand All @@ -154,7 +154,7 @@ def entity_from_protobuf(pb):
if is_list and len(value) > 0:
exclude_values = set(
value_pb.exclude_from_indexes
for value_pb in value_pb._pb.array_value.values
for value_pb in value_pb.array_value.values
)
if len(exclude_values) != 1:
raise ValueError(
Expand Down

0 comments on commit 0e5b718

Please sign in to comment.