At 10:35 PM 7/28/2009 -0500, Ian Bicking wrote:
On Tue, Jul 28, 2009 at 9:40 PM, P.J. Eby<p...@telecommunity.com> wrote:
> At 09:22 PM 7/28/2009 -0500, Ian Bicking wrote:
>>
>> I can see how this could go quite wrong, but maybe if installers touch
>> some file in the library directory anytime a package is
>> installed/reinstalled/removed/etc,
>
> You mean, like, the mtime of the directory itself? Â ;-)

Do directory mtimes get recursively updated?  I don't think they do.

That's not necessary; if imports use a cached listdir, then the children will get handled recursively.

So if you have a layout:

site-packages/
  zope/
    interface/
      __init__.py

And you update the package and update __init__.py, the mtime of
site-packages doesn't change, does it?

Nope, but at the top level, the fact that 'zope' is present is unchanged, as is the presence of an 'interface' subdirectory.


I'm saying if there was a file in site-packages/last_updated that gets
touched everytime an installer does anything in site-packages, then
you could cache (between processes) the lookups.

Since each invocation of the interpreter can have a different PYTHONPATH, the cache has to be per-directory, not global. If it's per-directory, then there's no real benefit over runtime caching, since you now have to open and read a file (instead of just reading the directory). And as I said, it's not realistic to think that opening and reading a file is going to beat opening and reading a directory for speed.

_______________________________________________
Distutils-SIG maillist  -  Distutils-SIG@python.org
http://mail.python.org/mailman/listinfo/distutils-sig

Reply via email to