Setting 10K domains to ALLOWED_HOSTS

I understand ALLOWED_HOSTS is used for security reasons - but what if I have many domains to add ?

What if 10,000 ? Is it safe to go about storing the domains in a text file and reading them and then setting it the array dynamically ?

If you have the code to read that file and build the ALLOWED_HOSTS list within the settings file, and don’t use the ORM, yes.