About 51 results
Open links in new tab
  1. python - Immutable vs Mutable types - Stack Overflow

    Nov 9, 2011 · In Python, think of variables as objects containing pointers to other objects, where everything is an object, and each object contains a bit specifying whether it is mutable or immutable, …

  2. oop - Mutable vs immutable objects - Stack Overflow

    Nov 2, 2018 · I'm trying to get my head around mutable vs immutable objects. Using mutable objects gets a lot of bad press (e.g. returning an array of strings from a method) but I'm having trouble …

  3. python - Hashable, immutable - Stack Overflow

    All of Python’s immutable built-in objects are hashable, while no mutable containers (such as lists or dictionaries) are. Objects which are instances of user-defined classes are hashable by default; they …

  4. python - Mutable vs. Immutable object specifically lists - Stack Overflow

    May 30, 2021 · In your second example, the list is still mutable, but you aren't mutating it. you're re-assigning it. In Python, when a function is called, the default behavior is for the scope of all variables …

  5. Mutable and Immutable in Python - Stack Overflow

    May 9, 2019 · I am new to Python and trying to understand the difference between mutable and immutable objects. One of the mutable types in Python is list. Let's say L = [1,2,3], then L has a id …

  6. python - Global on mutable vs immutable - Stack Overflow

    Oct 20, 2019 · 7 global has nothing to do with mutability. It changes the scope of a name, whether the global refers to a mutable or immutable object, so that you can assign a different value to the name. …

  7. Mutable versus Immutable objects for recursion in Python

    Feb 18, 2018 · In the immutable case, a new tuple object is created for each 'in-place' += operation (not so in place in this case). The results of the recursive calls are collected in entirely new tuples, …

  8. Why are python strings and tuples made immutable?

    Oct 8, 2009 · I am not sure why strings and tuples were made to be immutable; what are the advantages and disadvantage of making them immutable?

  9. What's the difference between lists and tuples? - Stack Overflow

    Mar 9, 2009 · The main difference between mutable and immutable is memory usage when you are trying to append an item. When you create a variable, some fixed memory is assigned to the variable.

  10. Why are integers immutable in Python? - Stack Overflow

    May 31, 2016 · The closest analogy will be int* versus an integer in python. In C, an integer at a location in memory can change, so in C the integer is mutable. In python, an integer is a reference, but …