[Python] Object class __slots__를 이용한 성능 개선
·
Python/Python
[Python] Object class __slots__를 이용한 성능 개선 0. 개요 Python에서는 Object attribute에 대해서 메모리는 더 적게 사용, 접근 속도는 더 빠르게 하는 방법이 있습니다. 바로, __slots__ 를 사용하는 방법 입니다. 기본적으로 Python은 객체 인스턴스 속성을 Dict를 사용 생성하며 Dict 형은 메모리를 추가적으로 필요로 합니다. slots 을 사용 하는 경우 class는 __dict__, __weakref__ 생성을 하지 않습니다. It restricts the valid set of attribute names on an object to exactly those names listed. Since the attributes are now fi..