# HG changeset patch
# User Laman
# Date 2022-03-03 22:36:36
# Node ID 0c78bfbee2186666ebb90e8ae067ff795cc21563
# Parent  91d8cd964f48b1df1608e407842f4e8e09bcdb58

compatibility with python<3.9

diff --git a/src/shamira/fft.py b/src/shamira/fft.py
--- a/src/shamira/fft.py
+++ b/src/shamira/fft.py
@@ -3,8 +3,8 @@
 import math
 import cmath
 import itertools
-from functools import cache
 
+from .util import cache
 from .gf256 import gfmul, gfpow
 
 # divisors of 255 and their factors in natural numbers
diff --git a/src/shamira/gf256.py b/src/shamira/gf256.py
--- a/src/shamira/gf256.py
+++ b/src/shamira/gf256.py
@@ -2,9 +2,11 @@
 
 """Arithmetic operations on Galois Field 2**8. See https://en.wikipedia.org/wiki/Finite_field_arithmetic"""
 
-from functools import reduce, cache
+from functools import reduce
 import operator
 
+from .util import cache
+
 
 def _gfmul(a, b):
 	"""Basic multiplication. Russian peasant algorithm."""
diff --git a/src/shamira/util.py b/src/shamira/util.py
new file mode 100644
--- /dev/null
+++ b/src/shamira/util.py
@@ -0,0 +1,7 @@
+try:
+	from functools import cache
+except ImportError:  # Python<3.9
+	from functools import lru_cache
+
+	def cache(f):
+		return lru_cache(maxsize=None)(f)