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
if ispkg:
pkgid = frozenid
pkgname = modname
+ pkgfiles = {pyfile: pkgid}
def iter_subs():
for frozenid, pyfile, ispkg in resolved:
assert not knownids or frozenid not in knownids, (frozenid, spec)
modname = frozenid.replace(pkgid, pkgname, 1)
else:
modname = frozenid
+ if pyfile:
+ if pyfile in pkgfiles:
+ frozenid = pkgfiles[pyfile]
+ pyfile = None
+ elif ispkg:
+ pkgfiles[pyfile] = frozenid
yield frozenid, pyfile, modname, ispkg, section
submodules = iter_subs()