Ask coding questions

← Back to all posts
Images Slow to Load/Reload in repl
YaacovIland

I'm using Pillow to generate image files in Python. When I run a program that generates an image file, the file can take a very long time (I timed a couple of runs and had 30 seconds and 125 seconds) to show up in the files list and to display in a pane in the repl.
If an existing image file was edited, it similarly took a long time for the repl pane showing the image to update. If I clicked on the file name in the files pane, the old image would show up instead of the new one.
After several weeks of annoyance, I started digging into the issue and discovered that the file list and displayed image both update when a change is saved in the code. So I can force an update by typing a character into the code and waiting for the save to complete, which is typically 1-2 seconds. This speeds things up immensely.
You can experiment with this behaviour in this repl: https://repl.it/@YaacovIland/Pillow-Test
The image will change depending on what width you give the program so you can view the update behaviour. You may need to fork the repl to try out the image update via code saving trick.

Voters
YaacovIland
esternin
PaoloAmoroso
Comments
hotnewtop
PaoloAmoroso

Great insight, thanks.

I reported a similar issue but missed your workaround because I evaluated the expressions directly in the REPL, not with run from the editor.

When I do an edit in the source just after running the code the image pane does appear almost instantaneously.

esternin

I do not see it being fixed. The only way i see an updated graphics pane is if i delete the .png file, then exit to the list of repls, reenter the repl i was in, wait for it to reload and then re-run.

Re-running without exit/reenter does not produce an update for me. Using a python repl. However i am a total newbie, so i may be misunderstanding the interface.

On a more fundamental level, why is show() not implemented?

PS I forgot to mention that any change to the source code does, indeed, provide a quick update of the graphics pane.

YaacovIland

@esternin That's really weird because this is now fixed for me. Whenever I run the repl I linked in my original comment, it updates the image immediately.

esternin

@YaacovIland Hmm... not my experience. Mind you, i use just pyplot, not pillow. I tried it in chrome/firefox on linux/android, no difference. I thought i would be clever and deleted the output.png file from inside the code before saving a new one, to ensure the file update. Well, re-running the code does not change anything. Worse, if i manually delete the .png file, and rerun the code, the .png file does not get recreated. I need to exit to my repls, and re-enter, and then rerun for the file to get recreated. A print statement works to the console, but .png file never shows up. This is a deal breaker for me, not just slow but unusable.

timmy_i_chen

Should be fixed now - sorry about that.

timmy_i_chen

Thanks for bringing this to our attention. We're looking into it.

PaoloAmoroso

I filed a bug report, you may want to upvote it.