In dd.bdd.BDD, some memoization happens per function call. The exception is the attribute BDD._ite_table that persists between calls to BDD.ite. Consider using an LRU cache via a decorator. Python 3 offers functools.lru_cache, and a backport to Python 2 exists. A side improvement will be more readable code. Should clear the cache during reordering, as done for _ite_table.
In
dd.bdd.BDD
, some memoization happens per function call. The exception is the attributeBDD._ite_table
that persists between calls toBDD.ite
. Consider using an LRU cache via a decorator. Python 3 offersfunctools.lru_cache
, and a backport to Python 2 exists. A side improvement will be more readable code. Should clear the cache during reordering, as done for_ite_table
.Places that would benefit from this change:
BDD.compose
BDD.cofactor
BDD.quantify
image
preimage
Benchmark the change in performance. Some packages other than the standard library worth considering:
pylru
cachetools
lru-dict