code: def singleton(cls):
      
      INSTANCES = {}
  
      def _singleton(*args, **kwargs):
          if cls not in INSTANCES:
              INSTANCES[cls] = cls(*args, **kwargs)
          return INSTANCES[cls]
  
      return _singleton
docs: 单例模式的装饰器： 在需要单例的类定义上加 @singleton 即可