Yes, that is usable, but note that if function is redefined, reloaded, or anything (e.g. in module reimport, or, if in python notebook, cell rerun), its address will change, therefore its hash too, so you will get the KeyError. Make sure that in those cases dictionary redefines too.