How to make st.selectbox not to upload all the values?

Iโ€™ve got st.selectbox(names[:end-1]) and len(names) is more than 200k
Is it possible to preload not the full data and add it to the list only if the person scrolls?

I donโ€™t think this is possible. Probably you will want to use a text input field where you set a filter, that upon leaving this field will be used as the filter for the selectbox. See the example below: the list included over >200k names, but if you enter a search pattern such as A, or Peter etc. it filters the selectbox to match these patterns. Of course filtering for a common name will return too many Names again, so I included a check where the list is shortened to 50 items.

import streamlit as st

names = ['John Miller'] * 50000
names = names + ['Mary Jane'] * 50000
names = names + ['Frank Miller'] * 50000
names = names + ['John Smith'] * 50000
names = names + ['Anne Taylor'] 
names = names + ['Steward Griffin'] 
names = names + ['Peter Griffin'] 

filter = st.text_input("filter",'A')
filtered_names = [k for k in names if filter in k]
if len(filtered_names) > 50:
    filtered_names = filtered_names[:50]

selection = st.selectbox("Select the key",index=0,options= filtered_names)
st.write(selection)

It would be nice if there was an autocomplete functionality similar to select2 library. Also it might be handy to have something like st.selectbox("Description", [key_list], [value_list]) option, where values are only for display purpose. Often you might want to give end-user better readable names. It is true that it could be implemented via intermediary steps by the developer, but would be nice to have it there as easy option.

I am not sure if autocomplete helps in this case as the normal behavior of a select from list widget is that the list is rendered fully filled first, then, as you type in a text, the list shrinks to matching records. This is actually done in st.selectbox, it is the initial list with 200k entries that are the problem, and would be in other systems as well.

Having a key and value list would be a new feature request, which I think would be very useful. I have asked for it myself in Label and values in in selectbox. However, the workaround given is so convenient that I donโ€™t miss not having separate key and value fields. Still, feel free to make a feature request on git.