# plotly.py Status

Last updated: 2026-04-16

## Current state

1 optimization shipped (split_multichar 2.05x), 5 targets analyzed with detailed findings. Deepcopy targets require mutation analysis before proceeding.

## Target repo

`~/Desktop/work/plotly_org/plotly.py` on branch `codeflash/optimize`

- **Fork**: KRRT7/plotly.py
- **Upstream**: plotly/plotly.py
- **Commit**: eb919e1ed (split_multichar optimization)

## Completed

| Target | Location | Result | Notes |
|---|---|---|---|
| split_multichar | `_plotly_utils/utils.py:394` | **2.05x** (1.76µs → 0.86µs) | Recursive → iterative, eliminate reduce/map |

## Analyzed (not yet optimized)

| Target | Location | Status | Verdict |
|---|---|---|---|
| _vals_equal numpy | `basedatatypes.py:5722` | Benchmarked | **Skip** — 1.34x only for shape mismatches, regresses common case |
| to_dict() deepcopy | `basedatatypes.py:3321` | Needs mutation analysis | convert_to_base64() modifies returned dict in-place |
| _set_compound_prop() double deepcopy | `basedatatypes.py:5361-5366` | Needs mutation analysis | Copies used for comparison, props assignment, orphan tracking |
| add_traces() deepcopy | `basedatatypes.py:2272` | Needs mutation analysis | Original code has "Optimize later if needed" comment |
| ColorValidator quadratic | `basevalidators.py:1370-1388` | Needs code reading | Validates array twice (validate + find_invalid) |

## Next steps

1. **ColorValidator (Target 4)**: Likely clean algorithmic improvement, no mutation risk
2. **Pick one deepcopy target**: add_traces() has clearest semantics (acknowledged by original devs)
3. **Add integration tests** before optimizing deepcopy targets — exercise mutation paths
4. **Consider copy-on-write**: Python 3.11+ dict COW might make shallow copies nearly free

## VM

Not yet provisioned. Initial work on local machine.

## PRs

| PR | Branch | Status | Description |
|---|---|---|---|
| (pending) | codeflash/optimize | Local | split_multichar 2.05x speedup |
