1 분 소요


Object

  • (general meaning)
    • a material thing that can be seen and touched
  • in programming
    • a combination of variables and functions that is in memory
  • Everything in Python is an object
    • integers
    • strings
    • functions
    • files
    • etc.


A Python Integer is more than just an integer

The standard Python implementation is written in C. This means that every Python object is simply a cleverly disguised C structure, which contains not only its value, but other information as well. For example, when we define an integer in Python, such as x = 10000, x is not just a ‘raw’ integer. It’s actually a pointer to a compound C structure, which contains several values.

image


image


Python variables

Variables are labels that are attached to the objects. Variables are not objects nor containers for objects; they only act as a pointer or a reference to the object.

image

= 연산을 하면 단순히 값을 복사하는 것이 아니라, 가리키는 pointer 자체를 옮기는 것이다.


Immutable objects

  • An immutable object cannot be changed after it is created
  • Immutable objects in Python: int, float, string, etc.

image

  • Reference link is broken if we assign a new object


Data types

  • Each object has a data type (for example, int, float, etc.)
  • The variable which points to the object does not have a specific type
    • No need to declare data types for variables

image

  • python에서는 변수를 만들어서 데이터를 저장할 때 데이터 타입을 지정해 주지 않는다.
    • 우리가 저장하려는 데이터를 전달하면, 그 타입에 따라서 object가 만들어지고 그 object에 의해 data type이 결정 된다.
    • 그래서 변수라는 애는 단순히 그 object를 가리키는 reference로써 기능을 하기 때문에 data type이 없는 것이다.


  • Each object has a data type, but variables don’t

image


Python Built-in Data types

image

댓글남기기