DEV Community

Discussion on: Why should I care about immutables in python?

Collapse
 
tomasruizt profile image
tomasruizt

I think one interesting topic when discussing immutability is data structures.

Why hasn't Python developed immutable lists and Dictionaries, like the Java community?

How do we provide clients of our code immutable containers, that are hard to accidentally tamper with?

Best,

Collapse
 
erickmendonca profile image
Erick Mendonça

Immutable lists are basically tuples. True immutability in Python requires some effort to achieve.

Collapse
 
himankbhalla profile image
himank

Immutability comes at a cost, and it is not necessarily a good solution in every situation. The primary basis of languages like c++, java, python etc is mutability. The flexibility we have with mutability also comes at a cost. Further, Python is deeply influenced by c++ and is geared for c++ programmers in a dynamic world. so mutable data structure is expected. It is a matter of language design and what problems or domain the language needs to cater to. Currently, I believe python is somewhere in the middle. Trying to do everything. whether it is oop, functional and what not.