Reconsider use of `tempfile` module
In the interest of improving the startup time of mkelvis (#2), is it even worth using tempfile? The data that mkelvis handles isn't particularly sensitive, so it could probably just construct a tempfile name from the elvis name--something like .${elvisname}.tmp or .${elvisname}.${progname}.tmp. According to that issue, the tempfile import takes ~10,000 us, which is 12.5% of the total runtime (80,000 us).
A potential problem of this approach is in the case where multiple mkelvis processes run at the same time, with common elvis names. I don't suspect that this will be common (or useful!).
Additionally, the program already makes the assumption that it is not being run from an archive (since decompressing on every invocation is too slow), evident in the use of jinja2.ModuleLoader with concrete filesystem paths and jinja2.FileSystemLoader. A more lightweight solution would be to use __file__, which would be guaranteed to exist in our case. Using importlib.resources results in tempfile also being imported.
After some rough testing, it appears that tempfile is also imported by jinja2.bccache--so no import-time improvements, except the removal of the importlib.resources import. The simpler tempfile creation is still a benefit though: safely creating a tempfile is relatively slow and we don't need that. Removing the use of tempfile.NamedTemporaryFile results in two less getrandom(...) syscalls.
The simpler tempfile creation is still a benefit though: safely creating a tempfile is relatively slow and we don't need that. Removing the use of
tempfile.NamedTemporaryFileresults in two lessgetrandom(...)syscalls.
After some timings, it appears that the speed difference is negligible and is within a margin of error. So the increased unsafe-ness is not worth it and the tempfile creation can be kept, but what about the use of importlib.resources.path? Using the with statement in the way it is in the code feels wrong. I don't want to wrap the whole program in it either. Perhaps use the "old way" of __file__ and path manipulation.