You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hot Module Replacement has been existed in JavaScript ecosystem for a long time, but Python web applications are still using full reloads by default.
To solve this situation, I implemented the hmr package, which does the fine-grained dependency tracking, on-demand reloading jobs. Here is a demo of what the results look like:
flask.mov
Obviously the a.py runs everytime in flask run --reload but reloads only when needed in hmr app.py. But everything else works fine (at least for this small demo)
You may say that user should use lazy imports and cache expensive calculations themselves, but in fact not every function can be cached, and lazy imports may lead to ugly code style. This can be solved with on-demand hot reloading without overhead. So I believe this is the future.
Although this is just a minimal demo, but I value hmr's potential in the Python ecosystem, and believe that with our efforts this is a reachable goal.
Tip
You can try the example above here with hmr app.py
About hmr, you can refer to its README for details.
The text was updated successfully, but these errors were encountered:
I really understand that this may never become a default behavior, and I can see your concern regarding potential risks that could arise.
However, I feel it would be a bit of a pity to close this issue so quickly. Would it be possible to move it to a discussion instead? I'd love to explore whether there might be others in the community who are interested in trying it out and contributing ideas.
Hot Module Replacement has been existed in JavaScript ecosystem for a long time, but Python web applications are still using full reloads by default.
To solve this situation, I implemented the
hmr
package, which does the fine-grained dependency tracking, on-demand reloading jobs. Here is a demo of what the results look like:flask.mov
Obviously the
a.py
runs everytime inflask run --reload
but reloads only when needed inhmr app.py
. But everything else works fine (at least for this small demo)You may say that user should use lazy imports and cache expensive calculations themselves, but in fact not every function can be cached, and lazy imports may lead to ugly code style. This can be solved with on-demand hot reloading without overhead. So I believe this is the future.
Although this is just a minimal demo, but I value hmr's potential in the Python ecosystem, and believe that with our efforts this is a reachable goal.
Tip
You can try the example above here with
hmr app.py
About
hmr
, you can refer to its README for details.The text was updated successfully, but these errors were encountered: