From the Python point of view, executing a function that is imported from another module or defined on the same module makes no difference.
From the Anvil point of view, all the server modules are imported when an http endpoint is called, so there is no difference.
If you are using the “Keep server running” option (you definitely should), then the http endpoints will be faster because Anvil will only load the app after it has been modified (and once in a while after the server goes to sleep).
If you can’t use the “Keep server running” and you have some modules that are slow to load, then importing only on demand could help: @lazy_load_imports decorator (for slow loading imports) (I have not tried this). But this will improve performances only because it will skip some unused import. Executing imported functions has the same speed regardless of how they are imported.