Optimisations for dill.memorise