fix: reduce memory footprint when loading TLDs by nandgator · Pull Request #362 · python-validators/validators

Opening a file and scanning it for every email validation is very inefficient.

That's true for repeated validations.

Is the memory footprint that much of a concern?

Yes, if the file is too, large and/or, system memory is insufficient.


What about a load_iana_tld() method?

It will load and store the TLDs once. If that method isn't called, it'll lookup the file every time. Associate that method with a dataclass, instead of using global variables.

A PR is welcome.