I recently discovered the "watch" command. With an autosave plugin in Vim, I can put some "print()" statements in my code and run "watch python3 mycode.py" in a small Tmux pane to get nearly instant feedback as I debug something. Or if I'm refactoring, I can do "watch pytest". It's pretty sweet.
What you should use instead is “inotifywait” [2] to execute your program(s) whenever there is a change. This way the program will run, for example, every time you save your changes. There are many utilities that make use of inotify (the library that powers inotifywait) some of them are fsnotify [3], fswatch [4] and watchexec [5].
[1] https://linux.die.net/man/1/watch
[2] https://linux.die.net/man/1/inotifywait
[3] https://github.com/fsnotify/fsnotify (written in Go — golang)
[4] https://github.com/emcrisostomo/fswatch (written in C++)
[5] https://github.com/watchexec/watchexec (written in Rust)