Nick Coghlan <ncogh...@gmail.com> added the comment:

The problem with changing the bytecode format is that code other than the 
import machinery reads the bytecode headers, so when we change the format, we 
need to consider the impact on that code. (Even my multiplication proposal 
above suffers from that problem)

A freshness check that would avoid the extra stat call, while still making the 
import system skeptical of the validity of the bytecode cache for just-edited 
sources would be to also check the source mtime against the *current* time: if 
they're the same within the resolution of the bytecode format (i.e. 1 second), 
then compile the code again even if the bytecode headers claims it's already up 
to date.

That way hot reloaders would be sure to pick up multiple edits to the source 
file properly, and would reliably be left with the final version loaded, rather 
than the first version from the final second of edits.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue31772>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to