Avoid unnecessary operations that can impact performance. This includes:

  1. Redundant data transformations:
  2. Minimize attribute lookups and string operations:

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.