Skip to content

Commit f89ddc2

Browse files
authored
Merge pull request #362 from yozachar/workshop
fix: reduce memory footprint when loading TLDs
2 parents 724262e + 9f5871b commit f89ddc2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/validators/domain.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99

1010

1111
def _iana_tld():
12-
"""Load IANA TLDs."""
12+
"""Load IANA TLDs as a Generator."""
1313
with Path(__file__).parent.joinpath("_tld.txt").open() as tld_f:
14-
return (line.strip() for line in tld_f.readlines()[1:])
14+
_ = next(tld_f) # ignore the first line
15+
for line in tld_f:
16+
yield line.strip()
1517

1618

1719
@validator

0 commit comments

Comments
 (0)