MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / __new__

Method __new__

machine_learning/automatic_differentiation.py:196–204  ·  view source on GitHub ↗

Executes at the creation of class object and returns if object is already created. This class follows singleton design pattern.

(cls)

Source from the content-addressed store, hash-verified

194 instance = None
195
196 def __new__(cls) -> Self:
197 """
198 Executes at the creation of class object and returns if
199 object is already created. This class follows singleton
200 design pattern.
201 """
202 if cls.instance is None:
203 cls.instance = super().__new__(cls)
204 return cls.instance
205
206 def __init__(self) -> None:
207 self.enabled = False

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected