Comparing the performance of streamlit and functools caching for pandas and polars. The results will surprise you!
Streamlit is my default framework for building both proof-of-concept demos and analytical dashboards. The simplicity of the framework allows quick development and easy maintenance. However, the dark side of simplicity is that it comes with in-built design assumptions that make it difficult to use as a top grade production tool. We will cover these in detail later, but the result of these assumptions is how slow Streamlit can be when processing and rendering your app.
In this post, I want to show you 2 methods to increase the speed of your Streamlit apps: using the built-in Streamlit caching functions and using the built-in functools caching functions. Both methods are anchored on the idea of caching, where, if something has already been triggered before, the output is saved to re-use later.
Before getting into the results, I feel it is important to understand 3 basic pieces of theory: how does Streamlit, Streamlit caching, and functools caching work under the hood.
PS: All images are authored by me, unless otherwise specified.