Skip to content

Enhance ASEAtomsData with available properties caching - #792

Closed
sundusaijaz wants to merge 2 commits into
devfrom
sa/mlff
Closed

sundusaijaz wants to merge 2 commits into
devfrom
sa/mlff

Conversation

@sundusaijaz

Copy link
Copy Markdown
Collaborator
  • feat: add caching for available properties in ASEAtomsData to improve performance
  • fix: reset cached properties when metadata is updated

* feat: add caching for available properties in ASEAtomsData to improve performance
* fix: reset cached properties when metadata is updated

@dajiaohuang dajiaohuang left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

One API behavior concern in the cache change: available_properties now returns the cached mutable List itself. Previously each property read built a fresh list from metadata. A caller that mutates the returned list (the public annotation remains List[str]) will now corrupt the cached value until metadata is reset, and later load_properties validation can then accept/reject properties incorrectly. Could this return a copy (or use an immutable internal representation) and add a small regression test for caller mutation?

@stefaanhessmann

Copy link
Copy Markdown
Collaborator

@dajiaohuang, thanks for the comment.
We changed the fix to return list(self._available_properties). However, it is added in #815, where we make a final spk2.x release and then continue in a new version 3.
I will close this PR :)

stefaanhessmann added a commit that referenced this pull request Oct 30, 2026
With load_properties left at its default of None, every sample reopened
the database to read the metadata, at about 0.55 ms per read. The
property names are now read once and kept until the metadata is written
again.

available_properties returns a copy, so that callers cannot change the
cached list and with it the validation of load_properties.

Based on #792.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

3 participants