python

time estimate in python

python에서 로거를 만든다거나 할때 코드의 시간을 측정하고 싶을때가 있다. 이때 python에서 기본으로 제공하는 time 모듈을 사용해보자 perf_counter * perf_counter [https://docs.python.org/3/library/time.html#time.perf_counter] * 전체 소요

check callable parameter in python

python에서 classmethod와 staticmethod 차이점은 첫번째 파라미터에 cls가 넘어오느냐 아니냐의 차이였다고 생각했는데 아래와 같은 동작 차이도 있었다. 호출가능여부를 체크할때에는 callable을 활용해야겠다. import inspect class ATest: @classmethod def test_classmethod(cls): pass @staticmethod def test_

pip

디펜던시 설치 pip install -r requirements.txt 최신 버전으로 설치 pip install --upgrade -r requirements.txt 현재 디펜던시 저장 pip freeze > requirements.txt

cachetools - python

python에서 간단하게 캐쉬를 사용할 수 있는 라이브러리가 있어서 소개한다. cachetools [http://cachetools.readthedocs.io/en/latest/] Support Cache * LFU(Least Frequently Used) * LRU(Least Recently Used) * RR(Random Replacement) * TTL(time-to-live) install pip