Skip to content

Mutable/immutable data types and object copies #5

Description

@tavareshugo

This document might be a nice inspiration for the distinction of mutable/immutable types, and how it relates to memory and making copies of objects.

To me (coming from R) it's easy to forget that the following code would result in a being changed:

a = [1, 2, 3]
b = a
b.append(4)   # both a and b become [1, 2, 3, 4]

It might be worth flagging this up with an example/exercise, as it might cause people silent bugs if they come from another language.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions