Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

perf: use deque for BFS queue in pytest_changed dependency traversal (#8514)

Giulio Leone6f665b18ed7e
diff --git a/packages/pytest_changed/__init__.py b/packages/pytest_changed/__init__.py
index d829e827f5..9891b8e819 100644
--- a/packages/pytest_changed/__init__.py
+++ b/packages/pytest_changed/__init__.py
@@ -12,6 +12,7 @@ from __future__ import annotations
import json
import subprocess
+from collections import deque
from pathlib import Path
import pytest
@@ -166,10 +167,10 @@ def find_affected_files(
"""
affected: set[Path] = set(changed_files)
visited: set[str] = set()
- queue: list[Path] = list(changed_files)
+ queue: deque[Path] = deque(changed_files)
while queue:
- current = queue.pop(0)
+ current = queue.popleft()
current_str = str(current)
if current_str in visited: