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

Ability to load attributes on demand then to cache them instead of loading them on object instantiation #1509

Open
eliasbenb opened this issue Apr 3, 2025 · 0 comments · May be fixed by #1510

Comments

@eliasbenb
Copy link

eliasbenb commented Apr 3, 2025

What is your feature request?

After profiling my program that relies on python-plexapi, I found that _loadData was the function with the highest CPU time (~65% of the program's total CPU time).

This is largely because python-plexapi loads all available attributes on object instantiation. Most of which never get used. Instead, I suggest attributes get loaded on demand and then cached (with the cache key changing whenever the _data attribute changes).

For my use cases, where I only need access to the ratingKey, guid, viewCount, lastViewedAt, rating attributes. Using on demand access would cut down _loadData's runtime by over 80% in this scenario (according to my rough estimate from the flame graph below).

Pyspy profiler flame graph:

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant