tulip-control / dd

Binary Decision Diagrams (BDDs) in pure Python and Cython wrappers of CUDD, Sylvan, and BuDDy
https://pypi.org/project/dd
Other
181 stars 39 forks source link

consider using LRU cache for BDD methods #22

Closed johnyf closed 3 years ago

johnyf commented 7 years ago

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.

Places that would benefit from this change:

Benchmark the change in performance. Some packages other than the standard library worth considering:

johnyf commented 3 years ago

Not sure whether this will be implemented.