Skip to content

PR: Performance improvements to colour.SpectralDistribution.wavelengths property and various definitions in colour.utilities.array module.#1067

Merged
KelSolaar merged 6 commits intodevelopfrom
performance/spectralditribution.shape
Nov 17, 2022
Merged

PR: Performance improvements to colour.SpectralDistribution.wavelengths property and various definitions in colour.utilities.array module.#1067
KelSolaar merged 6 commits intodevelopfrom
performance/spectralditribution.shape

Conversation

@tjdcs
Copy link
Copy Markdown
Contributor

@tjdcs tjdcs commented Nov 14, 2022

Summary

This PR makes small changes to improve the performance of several critical paths that are found throughout the code base. For example, tsplit and tstack are called very often. Additionally, the shape getter of SpectralDistribution is called very often in code that is manipulating spectral data. In one example calculating color rendering simulations, calling the .shape getter was responsible for around 10% of total execution time, but is now responsible for less than 0.1%

The particular examples that found these critical paths are not expected to be representative of all performance cases, none the less nearly all applications of colour-science should see some benefit.

Preflight

Code Style and Quality

  • Unit tests have been implemented and passed.
  • Mypy static checking has been run and passed.
  • Pre-commit hooks have been run and passed.
  • [N/A] New transformations have been added to the Automatic Colour Conversion Graph.
  • [N/A] New transformations have been exported to the relevant namespaces, e.g. colour, colour.models.

Documentation

  • [N/A] New features are documented along with examples if relevant.
  • [N/A] The documentation is Sphinx and numpydoc compliant.

.shape gets called a lot, and computing the min is slow
np.diff was slower. This is 250% than previous (timeit, default spectral shape)
@tjdcs tjdcs requested a review from KelSolaar November 14, 2022 02:11
@tjdcs tjdcs changed the title Performance/spectralditribution.shape Performance improvements to core SpectralDisribution and array.py Nov 14, 2022
@KelSolaar KelSolaar changed the title Performance improvements to core SpectralDisribution and array.py PR: Performance improvements to colour.SpectralDistribution.wavelengths property and various definitions in colour.utilities.array module. Nov 14, 2022
Copy link
Copy Markdown
Member

@KelSolaar KelSolaar left a comment

Choose a reason for hiding this comment

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

Thank you! I left a few minor notes but LGTM otherwise!

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