structa.collections
- class structa.collections.FrozenCounter(it)[source]
An immutable variant of the
collections.Counter
class from the Python standard library.This implements all readable properties and behaviours of the
collections.Counter
class, but excludes all methods and behaviours which permit modification of the counter. The resulting instances are hashable and can be used as keys in mappings.- classmethod from_counter(counter)[source]
Construct a
FrozenCounter
from acollections.Counter
instance. This is generally much faster than attempting to construct from the elements of an existing counter.The counter parameter must either be a
collections.Counter
instance, or aFrozenCounter
instance (in which case it is returned verbatim).