There are various implementations of this kind of autoreload system for Python but it always seems to come with compromises on semantics (different initialization order causes behaviour differences).
There are various implementations of this kind of autoreload system for Python but it always seems to come with compromises on semantics (different initialization order causes behaviour differences).
Python's import model is not without its flaws either, but at least you have a working application state, no need to fully initialize your app for every single request.
For simple apps that are contained within a few files, PHP is hard to beat for simplicity and speed.
I'm not sure if PHP stores any compiled binary or byte-code at all. Maybe it compiles it all on each request. It's super fast though, even with tons of imports.
My guess would be that it keeps compiled versions of each file in memory and on each request, it walks down the whole import path. And when it encounters a changed import, it compiles only that one.
Would be cool if someone with more knowledge could shed a light on what is actually happening.
It says:
Cache hits 4746528
Cache misses 38875
Both values go up every time I execute phpinfo().I wonder why. Shouldn't "Cache misses" only go up when a source file is changed?
PHP code is also typically far less complex than Python modules - modern PHP code consists of a single index.php with procedural code, and everything else is just class / function definitions, so there are no side effects.