๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿ | Python/ํŒŒ์ด์ฌ ๋ฌธ๋ฒ•

๋ฎคํ„ฐ๋ธ”(mutable)๊ณผ ์ด๋ฎคํ„ฐ๋ธ”(immutable)

by KASSID 2021. 9. 13.

๋ชฉ์ฐจ

    728x90

    ๋ฎคํ„ฐ๋ธ”(mutable)

    - ๋ณ€๊ฒฝ์ด ๊ฐ€๋Šฅํ•œ ๊ฐ์ฒด

    - ์ƒ์„ฑ ํ›„ ์ž์œ ๋กญ๊ฒŒ ๊ฐ’์„ ๋ณ€๊ฒฝ, ์ถ”๊ฐ€, ์‚ญ์ œ ๋“ฑ์ด ๊ฐ€๋Šฅํ•˜๋‹ค.

    - list, set, dictionary ๋“ฑ

    - ๋ณ€์ˆ˜์˜ ๊ฐ’์„ ๋ณ€๊ฒฝํ•˜๋ฉด ๊ฐ์ฒด ์ž์ฒด๋ฅผ ์—…๋ฐ์ดํŠธ ํ•œ๋‹ค. (๊ฐ’ ๋ณ€๊ฒฝ -> ํ• ๋‹น๋œ ๋ฉ”๋ชจ๋ฆฌ์— ์ „๋‹ฌ)

    - call by reference(์ฐธ์กฐ์— ์˜ํ•œ ํ˜ธ์ถœ)

     

    ์ด๋ฎคํ„ฐ๋ธ”(immutable)

    - ๋ณ€๊ฒฝ์ด ๋ถˆ๊ฐ€๋Šฅํ•œ ๊ฐ์ฒด

    - ์ƒ์„ฑ ํ›„ ๊ฐ’ ๋ณ€๊ฒฝ, ์ถ”๊ฐ€, ์‚ญ์ œ ๋“ฑ์ด ๋ถˆ๊ฐ€๋Šฅํ•˜๋‹ค.

    - ์ˆซ์ž, string, tuple ๋“ฑ

    - ๋ณ€์ˆ˜์˜ ๊ฐ’์„ ๋ณ€๊ฒฝํ•˜๋ฉด ๋‹ค๋ฅธ ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ•˜๊ณ  ๊ทธ ๊ฐ์ฒด์— ๋Œ€ํ•œ ์ฐธ์กฐ๋กœ ์—…๋ฐ์ดํŠธ ๋œ๋‹ค.

      (๊ฐ’ ๋ณ€๊ฒฝ -> ์ƒˆ๋กœ์šด ๋ฉ”๋ชจ๋ฆฌ์— ์ „๋‹ฌ)

    - call by value(๊ฐ’์— ์˜ํ•œ ํ˜ธ์ถœ)

    '๐Ÿ | Python > ํŒŒ์ด์ฌ ๋ฌธ๋ฒ•' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

    ๋ฌธ์ž์—ด ํฌ๋งคํŒ…  (0) 2021.09.18
    ์–•์€ ๋ณต์‚ฌ์™€ ๊นŠ์€ ๋ณต์‚ฌ  (0) 2021.09.13
    ๋ณ€์ˆ˜  (0) 2021.09.13
    while  (0) 2021.09.06
    for  (0) 2021.09.06

    ๋Œ“๊ธ€