Improve performance, streamline code in a LOT of places. Fixed bugs.#11
Conversation
Bugs fixed: - can only have a single reloading loop - now works with multiple - loop vars if reloading loop isn't first were wrong. - dumb regex looked at the first loop it could find, now getting vars using ast. Performance improvements: - now allows for the keyword only argument reload_after, which will only reload the code every n iterations - reduced total number of inspect calls - compile() the code first, before running it (only loops so far)
|
Hey, thanks a lot for the PR 🙏 Will have a look through the code sometime this week |
|
hey, i need to test this some more, i remembered that i haven't tested how well errors are handled, more specifically, syntax errors. I will test this over the next few days, and comment the results. sidenote: i use the black formatter, which is why the diff probably seems larger than expected. didn't mean to run it, but oh well. |
|
@julvo i have now reworked the way functions reload (no more loading specific line numbers!) and also fixed the issues with error handling, which was also streamlined some more. Its definitely ready for merge from my side, please do still test/review it. at this point i've basically rewritten the entire thing 😆 EDIT: scratch that, i broke the normal looping. back to work. EDIT: EDIT: fixed it |
no more string splitting and loading the source multiple files.
|
I think I'm finally done. Unless I think of some amazing way to make it work with while loops, but there most likely isn't one. |
|
@julvo whats the status on this? |
|
I'm currently quite busy, but hope to get around to it it on the weekend. As it's quite a substantial change, I want to review and test this properly. Generally open to extending the API, but may want to change the naming a bit. Initial idea for the new API is |
|
@julvo thats fine, and definitely not too hard to implement, will take a look today or tomorrow on changing that. i should probably also write some more unit tests for that new behavior. Generally, the infinite looping definitely isn't required and if that's what's holding up this PR from being merged, i would rather remove it for now and do a second PR with those features. |
also add handling of empty reloading in loop
|
Finally got around to implementing the suggested changes. |
|
Hey @laundmo, had a look at some of the patch last weekend. So far only the reloading decorator code - good job! I like the idea of filtering out the reloading decorator instead of remembering the inner function explicitly. Just wanted to let you know that I'm not forgetting to review this, just quite busy at the moment |
|
thanks for the notification, i was wondering about that.
take your time!
|
|
more than a month later, i already have quite a few people installing reloading directly from my fork, so i might just re-release under a new name because this is taking entirely too long. Would also allow me to do some more drastic changes. |
|
Just merged this. Sorry again for taking so long - it has been a busy period for me. Of course, feel free to maintain your own fork or also open issues on this repo closes #10 |
|
thanks, i created some issues to keep track of things that need doing, mostly so i wont forget |
Bugs fixed:
Performance improvements:
Reloading loop performance comparison:

ris the reload_afteroldrefers to whether this is the old version of the library.The benchmark code is avaliable on laundmo:benchmark
This is heavily related to #10