I want to subclass
dict
in python such that all the dictionaries of the sub-class are immutable.
I don't understand how does __hash__
affects the immutability, since in my understanding it just signifies the equality or non-equality of objects !
So, can __hash__
be used to implement immutability ? How ?
Update:
Objective is that common response from an API is available as a dict, which has to be shared as a global variable. So, that needs to be intact no matter what ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…