Skip to content

perf: load Munsell color reference CSV once at startup#363

Merged
johannesparty merged 1 commit intomainfrom
fix/cache-munsell-csv-at-startup
Apr 1, 2026
Merged

perf: load Munsell color reference CSV once at startup#363
johannesparty merged 1 commit intomainfrom
fix/cache-munsell-csv-at-startup

Conversation

@johannesparty
Copy link
Copy Markdown
Contributor

This is not a critical change, but it does make things more efficient and it isn't particularly complicated.

The 8,500-row CSV was being read on every call to list_soils(). Now loaded once at module level in config.py. Also precompute the numpy array for LAB_ref and use np.argmin instead of pd.DataFrame.idxmin in lab2munsell to avoid repeated pandas overhead.

Not really sure if want the changes in .pre-commit-config.yaml, but let's see how the automated tests go.

The 8,500-row CSV was being read on every call to list_soils(). Now
loaded once at module level in config.py. Also precompute the numpy
array for LAB_ref and use np.argmin instead of pd.DataFrame.idxmin
in lab2munsell to avoid repeated pandas overhead.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@johannesparty johannesparty requested a review from garobrik March 19, 2026 18:15
Copy link
Copy Markdown
Member

@garobrik garobrik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure! were you able to see how big a perf difference this made?

@johannesparty
Copy link
Copy Markdown
Contributor Author

sure! were you able to see how big a perf difference this made?

I don't think it made much performance difference, but it does feel better.
I didn't explicitly measure.

@johannesparty johannesparty merged commit 2694ffd into main Apr 1, 2026
4 checks passed
@johannesparty johannesparty deleted the fix/cache-munsell-csv-at-startup branch April 1, 2026 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants