Skip to content

Commit

Permalink
Merge tag 'v3.8.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Mar 28, 2021
2 parents 61fcac1 + d17d6e4 commit 2a2b782
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ v3.9.0
config, resulting in a ~20% performance improvement when
loading entry points.

v3.8.2
======

* #293: Re-enabled lazy evaluation of path lookup through
a FreezableDefaultDict.

v3.8.1
======

Expand Down
6 changes: 3 additions & 3 deletions importlib_metadata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import contextlib
import collections

from ._collections import freezable_defaultdict
from ._collections import FreezableDefaultDict
from ._compat import (
NullFinder,
Protocol,
Expand Down Expand Up @@ -710,8 +710,8 @@ class Lookup:
def __init__(self, path: FastPath):
base = os.path.basename(path.root).lower()
base_is_egg = base.endswith(".egg")
self.infos = freezable_defaultdict(list)
self.eggs = freezable_defaultdict(list)
self.infos = FreezableDefaultDict(list)
self.eggs = FreezableDefaultDict(list)

for child in path.children():
low = child.lower()
Expand Down
9 changes: 6 additions & 3 deletions importlib_metadata/_collections.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import collections


class freezable_defaultdict(collections.defaultdict):
# from jaraco.collections 3.3
class FreezableDefaultDict(collections.defaultdict):
"""
Mix-in to freeze a defaultdict.
Often it is desirable to prevent the mutation of
a default dict after its initial construction, such
as to prevent mutation during iteration.
>>> dd = freezable_defaultdict(list)
>>> dd = FreezableDefaultDict(list)
>>> dd[0].append('1')
>>> dd.freeze()
>>> dd[1]
Expand Down

0 comments on commit 2a2b782

Please sign in to comment.