Skip to content

Commit 96a7d62

Browse files
committed
perf: Materialize float collections once before the non-finite check
Copy the repeated field into a list once and run the finite check and the conversion on that list, instead of iterating the protobuf container for the check and again for the conversion. Signed-off-by: Edson <[email protected]>
1 parent e1c6870 commit 96a7d62

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎sdk/python/feast/feature_server_utils.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ def _value_to_native(v: Value) -> Optional[Any]:
9494
elif which in _FLOAT_SCALAR_FIELDS:
9595
return _float_to_native(getattr(v, which))
9696
elif which in _FLOAT_COLLECTION_FIELDS:
97-
vals = getattr(v, which).val
97+
vals = list(getattr(v, which).val)
9898
if all(map(math.isfinite, vals)):
99-
return list(vals)
99+
return vals
100100
return [_float_to_native(f) for f in vals]
101101
# bytes must be base64-encoded for JSON serialization
102102
elif which == "bytes_val":

0 commit comments

Comments
 (0)