No project description provided
Project description
streamlit-session-memo
A decorator for session-specific caching on Streamlit.
from streamlit_session_memo import st_session_memo
@st_session_memo
def load_big_model():
...
return model
model = load_big_model()
This is a simple wrapper around st.session_state that caches the return value of the decorated function to the session state and returns the cached value if the function is called again with the same arguments.
We have been doing this manually with code like the following, but this decorator makes it simpler.
# Boilerplate code for session-specific caching.
cache_key = f"{arg_1}_{arg_2}_{arg_3}"
if cache_key in st.session_state:
model = st.session_state[cache_key]
else:
result = load_expensive_model(arg_1, arg_2, arg_3)
st.session_state[cache_key] = result
model = result
Note that, this decorator is a lightweight wrapper around st.session_state that acts like the code snippet above, and does not provide any additional features such as mutation guards that st.cache_data provides.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file streamlit_session_memo-0.3.2.tar.gz.
File metadata
- Download URL: streamlit_session_memo-0.3.2.tar.gz
- Upload date:
- Size: 95.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7b020432790755092060cdbb77d89f4ab5c38c4ca537c6c19b07ae265ee371a
|
|
| MD5 |
41ae378c060e2fd2c4efde93f5a2d33a
|
|
| BLAKE2b-256 |
c048f3f98d98ed709d8b25408de3e799d6c6e2d271fc31aae4de479f7cbe7006
|
Provenance
The following attestation bundles were made for streamlit_session_memo-0.3.2.tar.gz:
Publisher:
main.yml on whitphx/streamlit-session-memo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
streamlit_session_memo-0.3.2.tar.gz -
Subject digest:
a7b020432790755092060cdbb77d89f4ab5c38c4ca537c6c19b07ae265ee371a - Sigstore transparency entry: 188187623
- Sigstore integration time:
-
Permalink:
whitphx/streamlit-session-memo@775a8e345e2d3ca46cbb6ace444f747e72bd1e2f -
Branch / Tag:
refs/tags/v0.3.2 - Owner: https://github.com/whitphx
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
main.yml@775a8e345e2d3ca46cbb6ace444f747e72bd1e2f -
Trigger Event:
push
-
Statement type:
File details
Details for the file streamlit_session_memo-0.3.2-py3-none-any.whl.
File metadata
- Download URL: streamlit_session_memo-0.3.2-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9f21d7a8c7724771341bc72693df3506e002a304a5e05a3d18b7eef04a7bece
|
|
| MD5 |
8053044891607cb5967cf03292aa56dd
|
|
| BLAKE2b-256 |
eaae1bad7e9cd7d6f2db97bca3b7183ea8ac25544bd375c18ceb58448278f258
|
Provenance
The following attestation bundles were made for streamlit_session_memo-0.3.2-py3-none-any.whl:
Publisher:
main.yml on whitphx/streamlit-session-memo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
streamlit_session_memo-0.3.2-py3-none-any.whl -
Subject digest:
a9f21d7a8c7724771341bc72693df3506e002a304a5e05a3d18b7eef04a7bece - Sigstore transparency entry: 188187629
- Sigstore integration time:
-
Permalink:
whitphx/streamlit-session-memo@775a8e345e2d3ca46cbb6ace444f747e72bd1e2f -
Branch / Tag:
refs/tags/v0.3.2 - Owner: https://github.com/whitphx
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
main.yml@775a8e345e2d3ca46cbb6ace444f747e72bd1e2f -
Trigger Event:
push
-
Statement type: