The reason for the 'slowness' is that i had fstab file where i automounted the external drive with a too long timeout.
Specifically i had on the options nofail,noatime,x-systemd-automount,x-systemd.device-timeout=1s
Omitting the option is even more disastrous btw, the default timeout is 90 seconds or something.
I ended up removing the automount and using '1ms' instead of '1s' for the timeout.
Removing the automount is not actually necessary, i think, and i might add it back, because it allows mount to happen even if you don't start gnome, and before autostart gnome programs although it conflicts/duplicates mountpoints with the gnome 'autostart' from autofs and can only be removed with the 'Disks' program in gnome, and requires using x-gvfs-hide to hide the ugly duplicated mountpoint.
I noticed this weird behavior where checking if paths existed with those paths being in /media mount points that are not mounted (that is: a external removable disc that is not connected) is exponentially slower than checking on local disc paths.
Is this a known bug? And how can i avoid it?
Should i just glob the mount points in '/media' and if a path starts in '/media' but isn't in the glob, skip it?
Is there a way to make this idea portable or is it hopeless to try?
python 3 path.exists() or os.path.exists(path) or open(path) is very slow if the path is on mountpoint that does not exist