News for hackers. Stuff that matters.
Re:Jurigged – Hot code reloading for Python by edem on Friday April 09, 2021 @02:34PM (#26754246)
Wait what? I thought Python was an interpreted language. Did I miss something?
Re:Jurigged – Hot code reloading for Python by breuleux on Friday April 09, 2021 @03:41PM (#26755125)
Python doesn't re-read a function's source code from the filesystem every time it calls it, and that would be a bad idea in general since you'd inadvertently crash your running programs during development.

This watches for changes on the filesystem and injects them into the running program as well as it can, basically keeping the current program state but with new behaviour.

This is kind of a footgun and there are many changes you can make that will crash or ruin the process, but if you're aware of the limitations it can be pretty useful.

Re:Jurigged – Hot code reloading for Python by nonameiguess on Friday April 09, 2021 @02:55PM (#26754556)
Imported modules are compiled to bytecode and frozen on import, so changing the code in-place won't change what actually get run when the code is called unless you clear the bytecode cache and re-import.

importlib provide a reload method for this purpose: https://docs.python.org/3.8/library/importlib.html#importlib...

Re:Jurigged – Hot code reloading for Python by dfilppi on Friday April 09, 2021 @03:26PM (#26754942)
Interesting. I've done it with no issues on both 27 and 36. Just edit the code directly in site-packages.
Re:Jurigged – Hot code reloading for Python by coldtea on Friday April 09, 2021 @03:06PM (#26754705)
So? Doesn't change the fact that once you've intepreted a function in some file, you've interpreted it and now it's in memory, and you're going to use the same as long as your program runs (even if you try to reload the module).

(I mean, this is the default case without using something like this project, or other tricks).