edgegraph.structure.singleton.get_all_semi_singleton_instances#
- edgegraph.structure.singleton.get_all_semi_singleton_instances(cls)#
Get all instances belonging to a given semi-singleton type.
This is a simple operation, in concept: it retrieves all the unique instances of the specified semi-singleton type. It may best be explained by example:
>>> from edgegraph.structure import singleton >>> class SemiSingle(metaclass=singleton.semi_singleton_metaclass()): pass >>> instances = [SemiSingle(i) for i in range(10)] # all unique instances >>> checked = singleton.get_all_semi_singleton_instances(SemiSingle) >>> set(checked) == set(instances) # use sets -- order may not be same True
Note
Internally, references to these instances are kept as the value side of a dictionary, which maintains insertion order. Therefore, some semblence of order may be present, but it shouldn’t be relied upon.
See also
semi_singleton_metaclass(), for more info about semi-singletonsclear_semi_singleton(), to reset a given semi-singleton