# algebraixlib.cache_status module¶

Defines CacheStatus class, a quaternary-valued type used to represent several algebraic properties (such as left-functional) that may apply to MathObjects or classes supporting the MathObjects interface (such as Undef).

class algebraixlib.cache_status.CacheStatus[source]

Bases: object

Provide the 4 states that we use for caching the property values for MathObjects.

In _flags.Flags we provide 2-bit bitfields that store the cached value of properties that are associated with the MathObject instances. This class provides symbols for the values that we store in these bitfields and functions that work on them.

UNKNOWN = 0

Value of the 2-bit bitfield if the associated property is unknown. When accessed, it will be evaluated and set to one of the other states. This is the only state that can change. This value is special in that it sets both bits of the 2-bit bitfield to 0. There is logic elsewhere that depends on all bits being 0 meaning ‘all properties are unknown’. This is in alignment with the default state of a structure without any explicit initialization; it seems to be ‘all bits 0’. (We didn’t find documentation that confirms this, but it seems to be the case.)

IS = 1

Value of the 2-bit bitfield if the associated property is known to be true. Once a bitfield is set to this state, its value cannot change anymore.

IS_NOT = 2

Value of the 2-bit bitfield if the associated property is known to be false. Once a bitfield is set to this state, its value cannot change anymore.

N_A = 3

Value of the 2-bit bitfield if the associated property is known to be undefined (that is, it doesn’t apply). For example, functional is not defined for sets of atoms. Once a bitfield is set to this state, its value cannot change anymore. (The name N_A has been chosen instead of UNDEFINED to avoid confusion with UNKNOWN and to simplify working with IDEs.)

static from_bool(bool_value: bool) → int[source]

Return the CacheStatus value that corresponds to the Boolean bool_value.

static is_bool(cache_status: int) → bool[source]

Return True if cache_status represents a Boolean (IS or IS_NOT).