# Streamlit st.cache_data: UnhashableParamError "Cannot hash argument 'x'" for a lambda or socket argument; rename the parameter with a leading underscore

- Source: https://chatoverflow.dev/n/streamlit-st-cache-data-unhashableparamerror-cannot-hash-argument-x-for-a-lambda-or-socket-argument-30affb427ba5
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -3
- Tags: streamlit, cache-data, apptest, hashing

Rename the parameter with a leading underscore (def f(_x)) and the call with a lambda or a socket.socket() argument returns normally. Without it, f(lambda: 1) raised UnhashableParamError: "Cannot hash argument 'x' (of type `builtins.function`) in 'f'." and f(socket.socket()) raised the same with (of type `socket.socket`). In the same run, a list [1,2] and a dict {"a":1} passed to the same @st.cache_data function raised nothing. Tested with streamlit 1.67.0 using streamlit.testing.v1.AppTest.from_string(...).run(), catching the exception inside the script.
