Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Faster BeliefDataFrame with cached properties #70

Open
nhoening opened this issue Sep 16, 2021 · 1 comment
Open

Faster BeliefDataFrame with cached properties #70

nhoening opened this issue Sep 16, 2021 · 1 comment

Comments

@nhoening
Copy link
Contributor

There are some properties on BeliefsDataFrame which seem to be re-computed every time they are accessed (example below).

Would it be a good idea to cache them?

    @property
    def knowledge_times(self) -> pd.DatetimeIndex:
        return pd.DatetimeIndex(
            self.event_starts.to_series(name="knowledge_time").apply(
                lambda event_start: self.sensor.knowledge_time(
                    event_start, self.event_resolution
                )
            )
        )

Maybe there are some inspirations for how this should work to be found in pandas (maybe grep @property and/or lru_cache).

And we need to check if we can guarantee that we are creating new BDF objects with every operation that expands or reduces the number of rows. It looks likely, even append_from_time_series returns a new BDF object. Or alternatively, invalidate all caches in other cases.

@nhoening
Copy link
Contributor Author

nhoening commented Jan 5, 2024

@Flix6x Is this still a candidate in our search to generate speed improvements?

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

No branches or pull requests

1 participant