On Fri, Sep 28, 2012 at 6:27 PM, Daniel Holth <[email protected]> wrote: > Is the new python 3.3 optimization documented anywhere? I am having trouble > finding it.
Well, it's mentioned several places in http://docs.python.org/dev/whatsnew/3.3.html, albeit rather obscurely. Most important mention is probably this: """The default finders used by import now utilize a cache of what is contained within a specific directory. If you create a Python source file or sourceless bytecode file, make sure to call importlib.invalidate_caches() to clear out the cache for the finders to notice the new file.""" Basically, the new system does for directories what older Pythons did for zipfiles: read in the a directory listing on first use, and keep it cached in memory. Unlike zipfiles, though, there's a stat() call done on each import to verify the directory listing isn't out of date. Technically, you don't need to manually flush the caches every time you put new modules in a directory, though. The only way for the cache to become invalid is if you try to import a module between two changes to the same directory, there is a potential race condition on filesystems with a highly granular filestamp type. For example, on a FAT filesystem, timestamps only change every two seconds, so if you make two changes to a directory within two seconds, and an import is attempted between those two changes, then the cache for that directory could become stale. A bit of info on this can be found at http://docs.python.org/dev/library/importlib.html#importlib.machinery.FileFinder _______________________________________________ Distutils-SIG maillist - [email protected] http://mail.python.org/mailman/listinfo/distutils-sig
