Skip to content

Cache a function with an nested list comprehension #2305

@successar

Description

@successar

Summary

When trying to cache a function with an nested list comprehension, streamlit doesn't allow outer iterator value within inner iterator.

Steps to reproduce

import streamlit as st

@st.cache()
def create_raw_data():
    production=[[outer + inner for inner in range(3)] for outer in range(5)]
    return production

production = create_raw_data()
st.write(production)

Expected behavior:

Should print [[0, 1, 2], [1, 2, 3], ..., [4, 5, 6]]

Actual behavior:

image

Is this a regression?

No.

Debug info

  • Streamlit version: (get it with 0.70.0)
  • Python version: (get it with 3.7.7)
  • Using Conda? PipEnv? PyEnv? Pex? Using conda env. Streamlit Installed with pip
  • OS version: Ubuntu 18.04
  • Browser version: Chrome

Additional information

Same as #1801 but that issue was closed. The provided solution there doesn't work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature:cacheRelated to `st.cache_data` and `st.cache_resource`type:bugSomething isn't working as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions