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

    Nov 9, 2011 · Other immutable types include some built-in types such as int, float, tuple and str, as well as some Python classes implemented in C. A general explanation from the "Data Model" chapter in …

  2. "Why" python data types are immutable - Stack Overflow

    Apr 3, 2015 · 9 Some Python data types are immutable because Python uses reference/pointer semantics. This means that whenever you assign an expression to a variable, you're not actually …

  3. What are the things that are allowed as keys in a python dictionary ...

    Jul 21, 2018 · A key must be immutable. That is the only limitations. For example, You can use a tuple as the key if the items within tuple are immutable : (1,2) But you can not do this ([1,2]) Read up more …

  4. 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 …

  5. Confusion regarding mutable and immutable data types in Python 2.7

    Jun 18, 2013 · Making integers immutable in Python is an attempt to mimic this, similar to how Strings are immutable in Java/C# to mimic this - so that the value in a variable that is an integer or floating …

  6. Why do we need tuples in Python (or any immutable data type)?

    Feb 1, 2010 · Python isn't nearly aggressive enough about using immutable data types to gain the full set of benefits, but using a language and programming model centered around immutability makes a …

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

    May 31, 2016 · I understand the differences between mutable and immutable objects in Python. I have read many posts discussing the differences. However, I have not read anything regarding WHY …

  8. How to make an immutable object in Python? - Stack Overflow

    @hlin117: Every parameter is passed as a reference to an object in Python, regardless of whether it is mutable or immutable. For immutable objects, it would be particularly pointless to make a copy – …

  9. Does Python have an immutable list? - Stack Overflow

    The main motivation for immutable types in Python is that they are usuable as dictionary keys and in sets.

  10. python - Why can't a set store mutable data types? - Stack Overflow

    Dec 29, 2020 · 3 I read in a book which stated due to "algorithmic underpinnings", only instances of immutable types can be added to a Python set, but it did not explain what are those "algorithmic …