object

    [Python] Strong Typing이란? with Object

    Python은 Strong Typing을 채택하고 있다. 이는 Object가 mutable type이냐 immutable type이냐에 상관없이 type이 변경되지 않음을 의미한다. 주의할 건, Object가 대상인 점이다. Python에서 Object는 memory에 할당된 일종의 데이터 덩어리(chunk)로 최소한 다음을 가지고 있어야 한다. 1. Value 2. Unique ID (CPython에선 memory address) : id(target_obj) 3. Type (type에 의해 같은 value라도 다르게 해석됨) : type(target_obj) 4. Reference Count (Garbage Collection을 위해 필요.) : sys.getrefcount(target_obj) 동시..

    [Python] Variable (and Object)

    1. 정의 Python에서 Variable은 Memory에 할당된 Ojbect를 참조하는 Name (=Reference)에 불과하다. 이 문서에서 Object는 Python에서의 Object로 type과 value, ID (CPython에서는 할당된 memory address), 그리고 reference count를 가지고 있는 데이터 덩어리를 가리키는 것으로 한정한다. Static Language에서의 Variable들이 type을 가지고 memory에 binding 되어있기 때문에, Static Language에서 variable들은 자신의 type와 다른 type의 memory 영역에 binding이 불가함. 다른 type의 memory영역과의 binding을 위해서는, (explicit) type..