| 883 | _instances: weakref.WeakValueDictionary[str, SingletonExpr] |
| 884 | |
| 885 | def __new__(cls, *args, _determ_token=None, **kwargs): |
| 886 | if not hasattr(cls, "_instances"): |
| 887 | cls._instances = weakref.WeakValueDictionary() |
| 888 | inst = super().__new__(cls, *args, _determ_token=_determ_token, **kwargs) |
| 889 | _name = inst._name |
| 890 | if _name in cls._instances and cls.__init__ == object.__init__: |
| 891 | return cls._instances[_name] |
| 892 | |
| 893 | cls._instances[_name] = inst |
| 894 | return inst |
| 895 | |
| 896 | |
| 897 | def collect_dependents(expr) -> defaultdict: |