zoukankan      html  css  js  c++  java
  • 一段神奇的代码

    # -*- coding: utf-8 -*-
    # @Time    : 2019/4/21 17:13
    # @Author  : Just
    # @Email   : 1785780475@qq.com
    # @File    : testCSS.py
    import threading
    import time
    
    
    class test(object):
        _instance_lock = threading.Lock()
    
        def __init__(self,name):
            self.name = name
    
        def __eq__(self, other):
            return self.name == other.name
    
        def __hash__(self):
            return hash(self.name)
    
        def __new__(cls, *args, **kwargs):
            with cls._instance_lock:
                if not hasattr(cls,'_instance'):
                    cls._instance = object.__new__(cls, *args, **kwargs)
                return cls._instance
    
        def __call__(self,func, *args, **kwargs):
            def inner(*args, **kwargs):
                start_time = time.time()
                result = func(*args, **kwargs)
                end_time = time.time()
                print('speend time:',end_time-start_time)
                return result
            return inner
    ghghgjhgjhgh
  • 相关阅读:
    树莓派学习记录
    ESP8266
    城轨列控系统
    VMware+CentOS7学习记录
    眼镜
    调试蜂鸣器驱动电路
    假期作业进度6
    假期作业进度5
    假期作业进度4
    假期作业进度3
  • 原文地址:https://www.cnblogs.com/just-do/p/10822749.html
Copyright © 2011-2022 走看看