[Perf] Optimize Python Slice for Structured Output using islice instead of [:] (#33593)

Signed-off-by: yewentao256 <zhyanwentao@126.com>
Signed-off-by: Wentao Ye <44945378+yewentao256@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
Wentao Ye
2026-02-24 09:02:36 -08:00
committed by GitHub
co-authored by gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
parent c38b8d5a31
commit 9ce8fad2a9
8 changed files with 23 additions and 16 deletions
+4 -1
View File
@@ -324,8 +324,11 @@ class StructuredOutputManager:
# Check if reasoning ends in *this* step
delta_from = request.num_computed_tokens - request.num_output_placeholders
all_token_ids = request.all_token_ids
start = (
delta_from if delta_from >= 0 else max(len(all_token_ids) + delta_from, 0)
)
if self.reasoner.is_reasoning_end_streaming(
all_token_ids, all_token_ids[delta_from:]
all_token_ids, itertools.islice(all_token_ids, start, None)
):
# Reasoning just ended, so we shouldn't advance til
# next pass