Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion chromadb/execution/expression/operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,13 @@ def __rmul__(self, other: Union[float, int]) -> "Mul":

def __truediv__(self, other: Union["Rank", float, int]) -> "Div":
"""Division: rank1 / rank2 or rank / value"""
other_rank = Val(other) if isinstance(other, (int, float)) else other
# Inline the isinstance check without tuple creation to avoid an extra allocation.
# Use direct type comparison for the common float and int cases for a micro-optimization.
t = type(other)
if t is float or t is int:
other_rank = Val(other)
else:
other_rank = other
return Div(self, other_rank)

def __rtruediv__(self, other: Union[float, int]) -> "Div":
Expand Down