get & restore functions implemented in Cython