Skip to content

Commit 1910bc2

Browse files
Minor typos and clarifications (#1215)
* Button guide typo * Clarify imported classes * Add LazyFrame to caching table Former-commit-id: f04fc75
1 parent 14aaad7 commit 1910bc2

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

content/develop/concepts/app-design/button-behavior-and-examples.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ begin.text_input('Name', key='name')
306306

307307
### Buttons to add other widgets dynamically
308308

309-
When dynamically adding widgets to the page, make sure to use an index to keep the keys unique and avoid a `DuplicateWidgetID` error. In this example, we define a function `display_input_row` which renders a row of widgets. That function accepts an `index` as a parameter. The widgets rendered by `display_input_row` use `index` within their keys so that `dispaly_input_row` can be executed multiple times on a single script rerun without repeating any widget keys.
309+
When dynamically adding widgets to the page, make sure to use an index to keep the keys unique and avoid a `DuplicateWidgetID` error. In this example, we define a function `display_input_row` which renders a row of widgets. That function accepts an `index` as a parameter. The widgets rendered by `display_input_row` use `index` within their keys so that `display_input_row` can be executed multiple times on a single script rerun without repeating any widget keys.
310310

311311
```python
312312
import streamlit as st

content/develop/concepts/app-design/custom-classes.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ We begin by covering some general-purpose patterns you can use for different typ
1919

2020
### Pattern 1: Define your class in a separate module
2121

22-
This is the recommended, general solution. If possible, move class definitions into their own module file and import them into your app script. As long as you are not editing the file where your class is defined, Streamlit will not re-import it with each rerun. Therefore, if a class is defined in an external file and imported into your script, the class will not be redefined during the session.
22+
This is the recommended, general solution. If possible, move class definitions into their own module file and import them into your app script. As long as you are not editing the files that define your app, Streamlit will not re-import those classes with each rerun. Therefore, if a class is defined in an external file and imported into your script, the class will not be redefined during the session, unless you are actively editing your app.
2323

2424
#### Example: Move your class definition
2525

@@ -74,7 +74,7 @@ st.write(isinstance(st.session_state.my_instance, MyClass))
7474
st.button("Rerun")
7575
```
7676

77-
Streamlit only reloads code in imported modules when it detects the code has changed. Thus, if you are actively editing the file where your class is defined, you may need to stop and restart your Streamlit server to avoid an undesirable class redefinition mid-session.
77+
Streamlit only reloads code in imported modules when it detects the code has changed. Thus, if you are actively editing your app code, you may need to start a new session or restart your Streamlit server to avoid an undesirable class redefinition.
7878

7979
### Pattern 2: Force your class to compare internal values
8080

content/develop/concepts/architecture/caching.md

+1
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ Or if you're lazy and don't want to think too much, look up your use case or ret
289289
| Running an ML model (inference) | pandas.DataFrame, str, int, dict, list | st.cache_data |
290290
| Creating or processing images | PIL.Image.Image, numpy.ndarray | st.cache_data |
291291
| Creating charts | matplotlib.figure.Figure, plotly.graph_objects.Figure, altair.Chart | st.cache_data (but some libraries require st.cache_resource, since the chart object is not serializable – make sure not to mutate the chart after creation!) |
292+
| Lazy computations | polars.LazyFrame | st.cache_resource (but may be better to use st.cache_data on the collected results) |
292293
| Loading ML models | transformers.Pipeline, torch.nn.Module, tensorflow.keras.Model | st.cache_resource |
293294
| Initializing database connections | pyodbc.Connection, sqlalchemy.engine.base.Engine, psycopg2.connection, mysql.connector.MySQLConnection, sqlite3.Connection | st.cache_resource |
294295
| Opening persistent file handles | \_io.TextIOWrapper | st.cache_resource |

0 commit comments

Comments
 (0)