Add a cache on slow get_deps function and others

Signed-off-by: Nicolas Iooss <nicolas.iooss_git@polytechnique.org>