Shared persistent memoisation library for GAP and other systems

Version 1.0
Released 2020-01-23

This project is maintained by Michael Torpey

The GAP 4 package `Memoisation’

Build Status Code Coverage Binder

A persistent memoisation framework for the GAP computational algebra system. Persistent memoisation is the practice of storing the output of a function permanently to a disk or a server so that the result can be looked up automatically in the future, avoiding any known results being recomputed unnecessarily.


GAP now has a package manager, which can be used to install any GAP package. To get the latest development version of the Memoisation package, run:

gap> LoadPackage("PackageManager");
gap> InstallPackage("");


Use MemoisedFunction to wrap a function and start saving its outputs to disk:

gap> double := x -> x * 2;;
gap> memo_double := MemoisedFunction(double);
<memoised function( x ) ... end>
gap> memo_double(3);
gap> memo_double(6.4);

This will store the outputs of the double function in a directory called memo/double/, in a machine-readable format. Subsequent calls of memo_double(3) will be looked up on disk instead of being recomputed.

One can specify various arguments to MemoisedFunction. For example:

gap> power := MemoisedFunction({x, y} -> x ^ y,
>                rec(funcname := "power_number",
>                    cache := "file://arithmetic_results",
>                    hash := k -> StringFormatted("{}_to_the_{}", k[1], k[2]),
>                    pickle := String,
>                    unpickle := Int));;
gap> power(2, 4);
gap> power(10, 5);

will store the outputs of power in human-readable files with descriptive filenames.

Many more options are available. See the package documentation for a full description.


Memoisation is free software; you can redistribute it and/or modify it under the terms of the BSD 3-clause license.

For details see the files and LICENSE.


Please cite this package as:

[TP20] M. Torpey & M. Pfeiffer, Memoisation (GAP package), Persistent memoisation in GAP, Version X.Y (20XX),


Memoisation was created as part of the OpenDreamKit project:

This part of the project is summarised in this report.

This infrastructure is part of a project that has received funding from the European Union's Horizon 2020 research and innovation programme under grant agreement No 676541.