The StateSpace class is very generally. For example, an instance can represent a state space in which each dimension has a different base (useful for models with nodes of different bases). Generality is an advantage in that is means we can use it in a lot of situations, but it sometimes comes at a performance cost. General functions cannot always make assumptions that would otherwise improve performance. For example, the StateSpace.encode method doesn't make use of any bit-level operations because there's no guarantee that the node-states will be Boolean.
Is it worth implementing a class hierarchy of state spaces that allow more efficient implementations of basic algorithms?
Proposed API
The hierarchy starts at the top-level with a maximally general state space.
class StateSpace(object):
"""Each dimension can have a different base, not necessarily Boolean"""
pass
Lower and lower levels have more specific constraints on them:
class UniformStateSpace(StateSpace):
"""Each dimension has the same base, not necessarily Boolean"""
pass
class BooleanStateSpace(UniformStateSpace):
"""Each dimension is Boolean"""
pass
The
StateSpace
class is very generally. For example, an instance can represent a state space in which each dimension has a different base (useful for models with nodes of different bases). Generality is an advantage in that is means we can use it in a lot of situations, but it sometimes comes at a performance cost. General functions cannot always make assumptions that would otherwise improve performance. For example, theStateSpace.encode
method doesn't make use of any bit-level operations because there's no guarantee that the node-states will be Boolean.Is it worth implementing a class hierarchy of state spaces that allow more efficient implementations of basic algorithms?
Proposed API
The hierarchy starts at the top-level with a maximally general state space.
Lower and lower levels have more specific constraints on them: