refactor(core): replace float('inf') with math.inf

Replace float('inf') and float('-inf') with math.inf and -math.inf from the math module for better readability and performance. Also clean up imports and remove unused speed comparison code.

No breaking changes.
This commit is contained in:
UncleCode
2025-03-04 18:23:55 +08:00
parent f334daa979
commit 415c1c5bee
5 changed files with 16 additions and 72 deletions

View File

@@ -12,6 +12,7 @@ from . import DeepCrawlStrategy
from ..types import AsyncWebCrawler, CrawlerRunConfig, CrawlResult, RunManyReturn
from math import inf as infinity
# Configurable batch size for processing items from the priority queue
BATCH_SIZE = 10
@@ -37,7 +38,7 @@ class BestFirstCrawlingStrategy(DeepCrawlStrategy):
filter_chain: FilterChain = FilterChain(),
url_scorer: Optional[URLScorer] = None,
include_external: bool = False,
max_pages: int = float('inf'),
max_pages: int = infinity,
logger: Optional[logging.Logger] = None,
):
self.max_depth = max_depth