-
Notifications
You must be signed in to change notification settings - Fork 4k
Description
Checklist
- I have searched the existing issues for similar feature requests.
- I added a descriptive title and summary to this issue.
Summary
@st.cache_data(hash_funcs=...) can be used to support hashing non-natively supported types as cache keys. However, this requires passing the hash_funcs parameter to every cache decorator.
I would like to be able to implement a method on my own types that Streamlit calls to make that type hashable.
This is technically already possible with __reduce__, but that can have unintended consequences: #6290 (comment)
Alternatively, I would like to be able to register my type once with a custom hashing function, by calling a function early during startup of the application, or by specifying it in a config file.
Why?
I use a (Pydantic) helper class throughout my Streamlit application that I would like to be able to hash to make intermediate functions cacheable.
How?
No response
Additional Context
A similar issue (#6290) was fixed by #6502, but this solution is quite verbose if you have many functions that receive your custom type.