1414import contextlib
1515import collections
1616
17+ from ._collections import freezable_defaultdict
1718from ._compat import (
1819 NullFinder ,
20+ Protocol ,
1921 PyPy_repr ,
2022 install ,
21- Protocol ,
2223)
23-
2424from ._functools import method_cache
2525from ._itertools import unique_everseen
2626
@@ -659,8 +659,8 @@ class Lookup:
659659 def __init__ (self , path : FastPath ):
660660 base = os .path .basename (path .root ).lower ()
661661 base_is_egg = base .endswith (".egg" )
662- self .infos = collections . defaultdict (list )
663- self .eggs = collections . defaultdict (list )
662+ self .infos = freezable_defaultdict (list )
663+ self .eggs = freezable_defaultdict (list )
664664
665665 for child in path .children ():
666666 low = child .lower ()
@@ -674,6 +674,9 @@ def __init__(self, path: FastPath):
674674 legacy_normalized = Prepared .legacy_normalize (name )
675675 self .eggs [legacy_normalized ].append (path .joinpath (child ))
676676
677+ self .infos .freeze ()
678+ self .eggs .freeze ()
679+
677680 def search (self , prepared ):
678681 infos = (
679682 self .infos [prepared .normalized ]
@@ -685,7 +688,7 @@ def search(self, prepared):
685688 if prepared
686689 else itertools .chain .from_iterable (self .eggs .values ())
687690 )
688- return list ( itertools .chain (infos , eggs ) )
691+ return itertools .chain (infos , eggs )
689692
690693
691694class Prepared :
0 commit comments