codeflash-agent/.codeflash/krrt7/plotly/plotly.py
Kevin Turcios 3ee9c22c8e
fix: resolve all ruff lint errors across repo (#38)
* fix: resolve all ruff lint errors across repo

Auto-fixed 31 errors (unused imports, formatting, simplifications).
Manually fixed 14 remaining:
- EXE001: removed shebangs from non-executable bench scripts
- C417: replaced map(lambda) with generator expression
- C901/PLR0915: extracted _write_and_instrument_tests from generate_ai_tests
- C901/PLR0912: extracted _parse_toml_addopts and _ini_section_name from modify_addopts
- RUF001/RUF002: replaced ambiguous Unicode chars (en dash, multiplication sign)
- FBT002: made boolean params keyword-only in report functions
- E402: moved `import re` to top of file in security reports

* fix: resolve pre-existing mypy errors across packages

- _testgen.py: annotate `generated` as `str` to avoid no-any-return
- _test_runner.py: use str() for TimeoutExpired stdout/stderr (bytes|str),
  remove unused type: ignore on proc.kill()
- _candidate_eval.py: annotate `speedup` as `float` to avoid no-any-return
  from lazy-loaded performance_gain
2026-04-23 10:22:42 -05:00
..
bench fix: resolve all ruff lint errors across repo (#38) 2026-04-23 10:22:42 -05:00
data Add optimization project scaffolding for plotly/plotly.py 2026-04-16 23:57:06 -05:00
conventions.md Add optimization project scaffolding for plotly/plotly.py 2026-04-16 23:57:06 -05:00
README.md Add optimization project scaffolding for plotly/plotly.py 2026-04-16 23:57:06 -05:00
setup.md Add optimization project scaffolding for plotly/plotly.py 2026-04-16 23:57:06 -05:00
status.md Add optimization project scaffolding for plotly/plotly.py 2026-04-16 23:57:06 -05:00

plotly.py Optimization

Performance optimization case study for plotly/plotly.py.

Results

Optimization Target Before After Improvement Status
Iterative split_multichar _plotly_utils/utils.py:394 1.76µs 0.86µs 2.05x Committed locally

Optimization Targets

6 pre-identified targets focused on deepcopy overhead, quadratic validation, and string parsing:

  1. to_dict() deepcopybasedatatypes.py:3321 (needs mutation analysis)
  2. _set_compound_prop() double deepcopybasedatatypes.py:5361-5366 (needs mutation analysis)
  3. add_traces() deepcopybasedatatypes.py:2272 (needs mutation analysis)
  4. ColorValidator quadratic validationbasevalidators.py:1370-1388 (needs code reading)
  5. _vals_equal() numpy comparisonbasedatatypes.py:5722 (skip — marginal gain)
  6. split_multichar()_plotly_utils/utils.py:394 (done — 2.05x)

Approach

  1. Profile hot paths in figure creation, serialization, and validation
  2. Benchmark with realistic workloads (large datasets, many traces)
  3. Submit individual PRs with hyperfine/codeflash benchmark numbers

Repo Structure

.
├── README.md              # This file
├── status.md              # Session state for resuming work
├── setup.md               # Environment setup notes
├── conventions.md         # Optimization target details
├── bench/                 # Benchmark scripts
│   ├── bench_split_multichar.py
│   └── bench_vals_equal.py
└── data/
    └── results.tsv        # Raw benchmark results