Closed aliabid94 closed 3 months ago
• | Name | Status | URL |
---|---|---|---|
Spaces | ready! | Spaces preview | |
Website | ready! | Website preview | |
Storybook | ready! | Storybook preview | |
:unicorn: | Changes | detected! | Details |
Install Gradio from this PR
pip install https://gradio-builds.s3.amazonaws.com/18ae92782cf6061a6ac1055698779537e9e17b34/gradio-4.32.2-py3-none-any.whl
Install Gradio Python Client from this PR
pip install "gradio-client @ git+https://github.com/gradio-app/gradio@18ae92782cf6061a6ac1055698779537e9e17b34#subdirectory=client/python"
Install Gradio JS Client from this PR
npm install https://gradio-builds.s3.amazonaws.com/18ae92782cf6061a6ac1055698779537e9e17b34/gradio-client-0.20.1.tgz
Package | Version |
---|---|
gradio |
minor |
state.change listener with deep hash check
Maintainers or the PR author can modify the PR title to modify this entry.
How expensive is this?
How expensive is this?
Pretty cheap I would think. It runs a hash function for every element in the nested object, and only gets run if there's a state change listener involved. In regular python the same hash function is called whenever you add any element to a dictionary or a set, so hashing is already quite optimized.
It might be worth adding a note on the State.change()
event listener docstring that this could get expensive if the State
object is a sequence with a large number of elements
It might be worth adding a note on the State.change() event listener docstring that this could get expensive if the State object is a sequence with a large number of elements
I don't think it's possible to directly add docs to the event of a single component. Regardless will update docs and guides on gr.State in a follow up PR.
state.change event listeners now do "deep checks", by deep hashing the old value. This makes @gr.render logic much cleaner. See demo/todo_list changes to see how much simpler the code is now because state values can be edited directly to induce a change.
Closes: https://github.com/gradio-app/gradio/issues/8436