[{"data":1,"prerenderedAt":328},["ShallowReactive",2],{"project-21268324":3},{"id":4,"name":5,"line":6,"line_source":7,"title":8,"url":9,"domain":10,"maker":11,"posted_at":12,"year":13,"points":14,"comments":15,"rank_in_year":16,"shown_in_year":17,"top":18,"tier":19,"category":20,"subcategory":21,"format":22,"keywords":23,"reception":28,"sentiment":29,"stance_mix":30,"scored_comments":35,"aspects":36,"strip":46,"post_text":47,"what":48,"said":80,"maker_in_thread":188,"shape":195,"grid":199,"attempts":291,"same_week":292,"maker_shows":33,"maker_hidden":320,"reader_version":321,"card":322},"21268324","reloading","Change Python code while it's running using a reloading loop","title","Show HN: Change Python code while it's running using a reloading loop","https:\u002F\u002Fgithub.com\u002Fjulvo\u002Freloading","github.com","julvo",1571215577,2019,187,39,214,2195,10,"notable","dev_tools","hot reloading library","library",[24,25,26,27],"python","hot reloading","live coding","development workflow","mixed",0.056,{"positive":31,"neutral":32,"mixed":33,"critical":34},6,12,2,7,27,{"execution":37,"idea":40,"design":43,"performance":45},{"positive":38,"critical":39},0,3,{"positive":41,"critical":42},5,4,{"positive":44,"critical":38},1,{"positive":38,"critical":38},[44,38,39,44,38,39,39,39,39,39,38,38,38,38,41,41,44,39,44,41,41,44,41,38,44,38,39,38,39,38,39,41,39,39,39,39,44,38,38],null,{"problem":49,"audience":61,"pricing":47,"motivation":47,"time_to_build":47,"stack":70,"openness":78,"stage":79,"team_size":79},{"value":50,"source":51,"evidence":52},"Changing Python code in a long-running loop requires restarting and losing progress.","commenter",[53,57],{"id":54,"by":55,"text":56},"21293401","deehouie","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.",{"id":58,"by":59,"text":60},"21295109","liuliu","Yeah. But wouldn't it be nice \u002F cool if the training process is interactive, reproducible, recordable and replayable?",{"value":62,"source":63,"evidence":64},"Python developers, especially those running long training jobs or development loops.","inferred",[65,66],{"id":54,"by":55,"text":56},{"id":67,"by":68,"text":69},"21292946","Waterluvian","Django's development mode aka \"runserver\" behaves a lot like this (as does a ton of different Node\u002FJavaScript systems, many of which are much more precise on what sub-components…",[71],{"value":72,"source":73,"evidence":74},"Python 3","maker",[75],{"id":76,"by":11,"text":77},"21290451","It only works with Python 3. Thanks for reminding me that I should add a note to the Readme.","open_source","unknown",{"praise":81,"objections":102,"requests":131,"questions":157,"alternatives":165},[82,91],{"value":83,"source":51,"evidence":84},"Useful for development workflows and long-running training",[85,86,90],{"id":54,"by":55,"text":56},{"id":87,"by":88,"text":89},"21291366","noobiemcfoob","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.",{"id":67,"by":68,"text":69},{"value":92,"source":51,"evidence":93},"Cool idea, similar to Lisp workflows",[94,98],{"id":95,"by":96,"text":97},"21295665","ken","This is how Lisp developers have worked for decades. It's been used for games before, too, e.g., https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FGame_Oriented_Assembly_Lisp",{"id":99,"by":100,"text":101},"21293172","technicalbard","Ah, something Common Lisp has had for over 30 years.",[103,117,124],{"value":104,"source":51,"evidence":105},"Hot reloading class definitions causes type identity bugs",[106,110,113],{"id":107,"by":108,"text":109},"21292507","uryga","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…",{"id":111,"by":11,"text":112},"21294262","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…",{"id":114,"by":115,"text":116},"21294420","orf","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…",{"value":118,"source":51,"evidence":119},"Hard to make general and only works for constants in loops",[120,123],{"id":121,"by":115,"text":122},"21297777","https:\u002F\u002Fyoutu.be\u002FIghyoR6ld60 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…",{"id":114,"by":115,"text":116},{"value":125,"source":51,"evidence":126},"Interactive claim is overstated; a Python shell is simpler",[127],{"id":128,"by":129,"text":130},"21295748","mrmuagi","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…",[132,139,146],{"value":133,"source":51,"evidence":134},"Support for method decorators",[135],{"id":136,"by":137,"text":138},"21293834","civilian","It'd be cool to be able to use this as a method decorator too!",{"value":140,"source":51,"evidence":141},"Keep running old code when errors occur",[142],{"id":143,"by":144,"text":145},"21290560","_carl_jung","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).",{"value":147,"source":51,"evidence":148},"Python 2 support",[149,153],{"id":150,"by":151,"text":152},"21290424","PerryCox","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 \"\u003Cinput>\", line 1, in…",{"id":154,"by":155,"text":156},"21290801","compressedgas","It does work in Python 2 with the following patch: ``` diff --git a\u002Freloading\u002Freloading.py b\u002Freloading\u002Freloading.py index 1d28e2f..1a5f981 100644 --- a\u002Freloading\u002Freloading.py +++…",[158],{"value":159,"source":51,"evidence":160},"How does it handle class redefinition?",[161,162],{"id":107,"by":108,"text":109},{"id":163,"by":108,"text":164},"21294355","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…",[166,171,176,184],{"value":167,"source":51,"evidence":168},"IPython %autoreload",[169,170],{"id":87,"by":88,"text":89},{"id":121,"by":115,"text":122},{"value":172,"source":51,"evidence":173},"Common Lisp and Lisp REPL reloading",[174,175],{"id":99,"by":100,"text":101},{"id":95,"by":96,"text":97},{"value":177,"source":51,"evidence":178},"importlib.reload",[179,183],{"id":180,"by":181,"text":182},"21295177","yomansat","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:…",{"id":111,"by":11,"text":112},{"value":185,"source":51,"evidence":186},"Django runserver",[187],{"id":67,"by":68,"text":69},{"comments":42,"answered":44,"key":189},[190,191,194],{"id":111,"text":112},{"id":192,"text":193},"21294071","Brilliant idea. That would make it useful for Keras, too, using decorated callbacks during training",{"id":76,"text":77},{"commenters":196,"max_depth":31,"maker_replies":42,"first_comment_mins":197,"lifespan_hours":198},30,3049,80,[200,202,204,206,207,211,213,216,218,222,223,227,230,233,235,239,240,243,244,245,247,250,251,253,254,256,257,258,261,264,267,268,270,273,274,277,280,283,287],[107,38,44,201,108,38],"project\u002Fcritical\u002Fexecution",[111,38,38,203,11,44],"project\u002Fneutral\u002Fexecution",[163,38,39,205,108,38],"project\u002Fneutral\u002Fidea",[114,38,44,201,115,38],[208,38,38,209,210,38],"21295829","commenter\u002Fneutral\u002Fnone","znpy",[121,38,39,212,115,38],"project\u002Fmixed\u002Fexecution",[214,38,39,203,215,38],"21295675","nerdponx",[217,38,39,203,108,38],"21296599",[219,44,39,220,221,38],"21291544","project\u002Fmixed\u002Fidea","throwaway66920",[95,44,39,205,96,38],[224,33,38,225,226,38],"21290809","other\u002Fneutral\u002Fnone","Torwald",[228,33,38,225,229,38],"21291012","kamyarg",[231,33,38,225,232,38],"21291649","marcpaq",[234,33,38,225,226,38],"21299367",[236,39,41,237,238,38],"21290410","project\u002Fpositive\u002Fidea","ovi256",[54,42,41,237,55,38],[241,42,44,242,129,38],"21294444","project\u002Fcritical\u002Fidea",[58,42,39,205,59,38],[128,42,44,242,129,38],[87,41,41,246,88,38],"project\u002Fpositive\u002Fdesign",[248,31,41,237,249,38],"21291739","kaffeemitsahne",[99,34,44,242,100,38],[136,252,41,237,137,38],8,[192,252,38,237,11,44],[150,255,44,201,151,38],9,[76,255,38,203,11,44],[154,255,39,203,155,38],[259,255,38,260,11,44],"21290810","maker\u002Fpositive\u002Fexecution",[262,255,39,203,263,38],"21295131","progval",[265,255,38,209,266,38],"21295251","kbd",[180,18,39,205,181,38],[67,269,41,237,68,38],11,[271,269,39,272,137,38],"21293714","project\u002Fneutral\u002Fperformance",[143,32,39,205,144,38],[275,32,39,203,276,38],"21290631","ianai",[278,32,39,203,279,38],"21291864","earenndil",[281,32,44,242,282,38],"21293175","rcfox",[284,285,38,225,286,38],"21298719",13,"kazinator",[288,289,38,225,290,38],"21294087",14,"potta_coffee",[],[293,298,302,306,310,315],{"id":294,"name":295,"points":296,"category":297},"21231208","Bel",1288,"languages",{"id":299,"name":300,"points":301,"category":20},"21215484","Spider Pro",391,{"id":303,"name":304,"points":305,"category":20},"21270424","Pipedream",245,{"id":307,"name":308,"points":309,"category":297},"21234891","dial",190,{"id":311,"name":312,"points":313,"category":314},"21253850","Alt-tab-macos",156,"productivity",{"id":316,"name":317,"points":318,"category":319},"21239930","Slouch Stoppah",153,"hardware",false,"v2",{"id":323,"name":5,"line":6,"ai":320,"cat":20,"year":13,"points":14,"comments":15,"rec":28,"s":324,"top":18,"kw":325,"maker":11,"domain":10,"tier":19,"attempts":38,"strip":326,"url":9,"mix":327,"praise":83,"objection":104,"sub":21},21268324,0.06,[24,25,26,27],"103103333300005513155150103030353333100",[31,32,33,34],1794036582018]