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
9 changes: 5 additions & 4 deletions chromadb/execution/expression/operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,10 +525,11 @@ class Limit:

def to_dict(self) -> Dict[str, Any]:
"""Convert the Limit to a dictionary for JSON serialization"""
result = {"offset": self.offset}
if self.limit is not None:
result["limit"] = self.limit
return result
# Fast path: avoid .get and dict manipulation
if self.limit is None:
return {"offset": self.offset}
# Avoid first initializing a partial dict then adding to it
return {"offset": self.offset, "limit": self.limit}

@staticmethod
def from_dict(data: Dict[str, Any]) -> "Limit":
Expand Down