You can use a plugin manager like https://github.com/marlonrichert/zsh-snap to cache the output of these commands. Using something like the packages version number as the cache key will ensure that it gets regenerated only once per package update as opposed to every shell launch.