Avoid unnecessary operations that can impact performance. This includes: 1. Redundant data transformations: - Load data directly from sources instead of creating temporary copies
Avoid unnecessary operations that can impact performance. This includes:
Example of improvements:
# Bad - Unnecessary string conversion and temporary storage
content = path.read_text(encoding="utf-8")
pyproject = tomllib.loads(content)
# Good - Direct loading
pyproject = tomllib.loads(path.read_text(encoding="utf-8"))
# Bad - Redundant str conversion in logging
log.debug("Selected choice: %s", str(node))
# Good - Let logging handle the conversion
log.debug("Selected choice: %s", node)
These optimizations are particularly important in performance-critical paths and frequently executed code sections.
Enter the URL of a public GitHub repository