Skip to content

Commit 45ca1c0

Browse files
bpo-45020: Do not freeze <pkg>/__init__.py twice. (gh-28635)
Currently we're freezing the __init__.py twice, duplicating the built data unnecessarily With this change we do it once. There is no change in runtime behavior. https://bugs.python.org/issue45020
1 parent bf5d168 commit 45ca1c0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Tools/scripts/freeze_modules.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,20 @@ def _parse_spec(spec, knownids=None, section=None):
221221
if ispkg:
222222
pkgid = frozenid
223223
pkgname = modname
224+
pkgfiles = {pyfile: pkgid}
224225
def iter_subs():
225226
for frozenid, pyfile, ispkg in resolved:
226227
assert not knownids or frozenid not in knownids, (frozenid, spec)
227228
if pkgname:
228229
modname = frozenid.replace(pkgid, pkgname, 1)
229230
else:
230231
modname = frozenid
232+
if pyfile:
233+
if pyfile in pkgfiles:
234+
frozenid = pkgfiles[pyfile]
235+
pyfile = None
236+
elif ispkg:
237+
pkgfiles[pyfile] = frozenid
231238
yield frozenid, pyfile, modname, ispkg, section
232239
submodules = iter_subs()
233240

0 commit comments

Comments
 (0)