Re: [Python-Dev] Importing .pyc in -O mode and vice versa

"Martin v. Löwis" wrote:
Greg Ewing schrieb:
I think I'd be happy with having to do that explicitly. I expect the vast majority of Python programs don't need to track changes to the set of importable modules during execution. The exceptions would be things like IDEs, and they could do a cache flush before reloading a module, etc.
That would be a change in behavior, of course.
Currently, you can put a file on disk and import it immediately; that will stop working. I'm pretty sure that there are a number of applications that rely on this specific detail of the current implementation (and not only IDEs).
Would it be reasonable to always do a stat() on the directory, reloading if there's been a change? Would this be reliable across platforms?
Tim Delaney

Delaney, Timothy (Tim) wrote:
Would it be reasonable to always do a stat() on the directory, reloading if there's been a change? Would this be reliable across platforms?
To detect a new shadowing you'd have to stat all the directories along sys.path, not just the one you think the file is in. That might wipe out most of the advantage.
It would be different on platforms which provide a way of "watching" a directory and getting notified of changes. I think MacOSX, Linux and Windows all provide some way of doing that nowadays, although I'm not familiar with the details.
-- Greg
participants (2)
-
Delaney, Timothy (Tim)
-
Greg Ewing