python에서 로거를 만든다거나 할때 코드의 시간을 측정하고 싶을때가 있다.
이때 python에서 기본으로 제공하는 time 모듈을 사용해보자
perf_counter
* perf_counter [https://docs.python.org/3/library/time.html#time.perf_counter]
* 전체 소요
pymongo [https://api.mongodb.com/python/current/]나 mongoengine
[http://docs.mongoengine.org/](내부는 pymongo)에서 test에서 mongodb에 데이터가 잘 들어가는지 확인하고
싶을때 실제 DB에 붙는게 부담스럽기도 하고 DB를 테스트 할때마다 띄우는것도 쉽지가
python에서 classmethod와 staticmethod 차이점은 첫번째 파라미터에 cls가 넘어오느냐 아니냐의 차이였다고 생각했는데
아래와 같은 동작 차이도 있었다.
호출가능여부를 체크할때에는 callable을 활용해야겠다.
import inspect
class ATest:
@classmethod
def test_classmethod(cls):
pass
@staticmethod
def test_
디펜던시 설치
pip install -r requirements.txt
최신 버전으로 설치
pip install --upgrade -r requirements.txt
현재 디펜던시 저장
pip freeze > requirements.txt
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