reloading

Dev tools

hot reloading library

SHOW HN2019

reloading

Change Python code while it's running using a reloading loop

github.com

#python#hot reloading#live coding#development workflow

187points
39comments
#214of 2,195 in 2019
Top 10%of 2019 by points

How HN took it

MixedNo clear lean

6 positive, 12 neutral or asking, 2 mixed, 7 critical, out of 27 comments about the project. Thread score +0.06.

Idea: 5 for, 4 againstExecution: 0 for, 3 againstDesign: 1 for, 0 against

The thread, comment by comment

Each row is a top-level comment and its replies, in HN's order. Select a cell to open that comment on HN.

positive neutral or mixed critical about another commenter or something else the maker

What HN said

What people liked

  • Useful for development workflows and long-running training

    From 3 comments
    • This is a great debugging tool for deep learning. Often your code might have been running for 20 hrs on 16 GPUs and you just don't want to restart from scratch again.
      deehouie on HN
    • Really nice tool! I often develop in a similar pattern (though not quite as functional) using IPython and it's %autoreload magic. This looks a lot cleaner.
      noobiemcfoob on HN
    • Django's development mode aka "runserver" behaves a lot like this (as does a ton of different Node/JavaScript systems, many of which are much more precise on what sub-components…
      Waterluvian on HN
  • Cool idea, similar to Lisp workflows

    From 2 comments
    • This is how Lisp developers have worked for decades. It's been used for games before, too, e.g., https://en.wikipedia.org/wiki/Game_Oriented_Assembly_Lisp
      ken on HN
    • Ah, something Common Lisp has had for over 30 years.
      technicalbard on HN

Objections

  • Hot reloading class definitions causes type identity bugs

    From 3 comments
    • i wrote something similar a while ago, and it gave rise to a pretty head-scratching bug... my code was doing something like ``` if type(x) is Foo: ``` and mysteriously failed for…
      uryga on HN
    • That's a pain to debug. A similar thing happened to me with reload from Python's importlib. In the case of the reloading loop I think this will only happen when redefining the…
      julvo on HN
    • I did a talk on this recently at EuroPython. Hot reloaders are really, really really hard to implement in Python in the general case (I.e not an IPython shell). You run into…
      orf on HN
  • Hard to make general and only works for constants in loops

    From 2 comments
    • https://youtu.be/IghyoR6ld60 I didn't go into as much detail as I would have liked about hot reloaders, but the tl;dr is that if you have a _single_ reference to something, then…
      orf on HN
    • I did a talk on this recently at EuroPython. Hot reloaders are really, really really hard to implement in Python in the general case (I.e not an IPython shell). You run into…
      orf on HN
  • Interactive claim is overstated; a Python shell is simpler

    From 1 comment
    • Not sure I totally agree that this achieves those goals, but I can't argue they would be ideal goals. >interactive AFAIK, as you type python code it will execute with the changes…
      mrmuagi on HN

Requests

  • Support for method decorators

    From 1 comment
    • It'd be cool to be able to use this as a method decorator too!
      civilian on HN
  • Keep running old code when errors occur

    From 1 comment
    • This is awesome. A nice improvement would be to have the loop continue with the old code when there are errors (rather than pausing iteration).
      _carl_jung on HN
  • Python 2 support

    From 2 comments
    • Anyone else getting this error? I tried on Debian 9 and MacOS 10.14.6 after installing via pip. ``` import reloading Traceback (most recent call last): File "<input>", line 1, in…
      PerryCox on HN
    • It does work in Python 2 with the following patch: ``` diff --git a/reloading/reloading.py b/reloading/reloading.py index 1d28e2f..1a5f981 100644 --- a/reloading/reloading.py +++…
      compressedgas on HN

Questions

  • How does it handle class redefinition?

    From 2 comments
    • i wrote something similar a while ago, and it gave rise to a pretty head-scratching bug... my code was doing something like ``` if type(x) is Foo: ``` and mysteriously failed for…
      uryga on HN
    • yeah, importlib.reload caused mine as well! i'm wondering if there's a way to avoid that... maybe a @reloadable class decorator that saves a reference to each object you…
      uryga on HN

Alternatives named

  • IPython %autoreload

    From 2 comments
    • Really nice tool! I often develop in a similar pattern (though not quite as functional) using IPython and it's %autoreload magic. This looks a lot cleaner.
      noobiemcfoob on HN
    • https://youtu.be/IghyoR6ld60 I didn't go into as much detail as I would have liked about hot reloaders, but the tl;dr is that if you have a _single_ reference to something, then…
      orf on HN
  • Common Lisp and Lisp REPL reloading

    From 2 comments
    • Ah, something Common Lisp has had for over 30 years.
      technicalbard on HN
    • This is how Lisp developers have worked for decades. It's been used for games before, too, e.g., https://en.wikipedia.org/wiki/Game_Oriented_Assembly_Lisp
      ken on HN
  • importlib.reload

    From 2 comments
    • FYI there's also reload(module) which is a built-in function. One great use-case I've come across is in developing a network proxy for game packet interception, see:…
      yomansat on HN
    • That's a pain to debug. A similar thing happened to me with reload from Python's importlib. In the case of the reloading loop I think this will only happen when redefining the…
      julvo on HN
  • Django runserver

    From 1 comment
    • Django's development mode aka "runserver" behaves a lot like this (as does a ton of different Node/JavaScript systems, many of which are much more precise on what sub-components…
      Waterluvian on HN

Category, keywords, summaries and labels on this page were made by AI (Thread Reader v2) and not checked by hand. Each point links to the comments it came from.

Add a badge to your READMEShown on HackerShow
[![Shown on HackerShow](https://hackershow.org/badge.svg)](https://hackershow.org/show/21268324)