Skip to content
Closed
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
15 changes: 12 additions & 3 deletions codeflash/languages/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
# This allows `from codeflash.languages.base import FunctionInfo` to work at runtime
def __getattr__(name: str) -> Any:
if name == "FunctionInfo":
from codeflash.discovery.functions_to_optimize import FunctionToOptimize
from codeflash.discovery.functions_to_optimize import \
FunctionToOptimize

return FunctionToOptimize
msg = f"module {__name__!r} has no attribute {name!r}"
Expand Down Expand Up @@ -185,13 +186,21 @@ def matches_include_patterns(self, name: str) -> bool:
"""Check if name matches any include pattern."""
if not self._include_regexes:
return True
return any(regex.match(name) for regex in self._include_regexes)
# Use an explicit loop to avoid generator allocation overhead.
for regex in self._include_regexes:
if regex.match(name):
return True
return False

def matches_exclude_patterns(self, name: str) -> bool:
"""Check if name matches any exclude pattern."""
if not self._exclude_regexes:
return False
return any(regex.match(name) for regex in self._exclude_regexes)
# Use an explicit loop to avoid generator allocation overhead.
for regex in self._exclude_regexes:
if regex.match(name):
return True
return False


@dataclass
Expand Down
Loading