'Dev Notes:
We make a lib for a particular sequence of dirs a singleton because:
1. The sequence of dirs for a language\'s import path tends to
not change, so the same object will tend to get used.
2. This allows caching of filesystem lookups to be done naturally
on the LangDirsLib instance.
To ensure that this cache doesn\'t grow unboundedly we only allow
there to be N cached LangDirsLib\'s. A good value for N is when
there are relatively few cache misses. Ideally we\'d want to
count the number of cache misses (i.e. LangDirsLib instance
creations) for a number of "typical" uses of codeintel -- i.e. a
long running Komodo profile. Failing that we\'ll just use N=10.'

def get_lib(self, name, dirs):

    assert isinstance(dirs, (tuple, list))
    canon_dirs = tuple(set((abspath(normpath(expanduser(d))) for d in dirs)))
    if (canon_dirs in self._dirslib_cache):
        return self._dirslib_cache[canon_dirs]
    langdirslib = LangDirsLib(self, self._lock, self.lang, name, canon_dirs)
    langdirslib.ensure_all_dirs_scanned()
    self._dirslib_cache[canon_dirs] = langdirslib
    return langdirslib
