Update
Gareth Rhys was right that points 1 and 3 were invalid in this case. Although I think that points 2 and 4 are still relevant, so I will leave theses here.
(I noticed that the request.POST object of both Pyramid (Pylon) and Django is some form of MultiDict . Therefore, perhaps this is a more common practice than making request.POST immutable.)
I can't speak for Django guys, although it seems to me that this may be due to some of these reasons:
Execution . immutable objects are βfasterβ over mutable ones, since they allow for significant optimization. An immutable object means that we can allocate space for it during creation, and the requirements for space do not change. Because of this, it also has things like copy efficiency and comparison efficiency. QueryDict > Edit : This does not apply to QueryDict , as Gareth pointed out.- In the case of
request.POST it seems that no activity on the server side will need to change the request data. And, therefore, immutable objects are more suitable, not to mention the fact that they have a significant advantage. Immutable objects can be used as dict keys, which I suppose can be very useful somewhere in Django .. Edit : my error, immutable, does not directly imply hashing; Hashable objects are generally immutable.- When you go through
request.POST (especially third-party plugins and exits), you can expect this request object from the user to remain unchanged.
To some extent, are these reasons also typical responses to "immutable vs mutable"? question. I am sure there are far more design considerations in Django than mentioned above.
KZ Sep 27 2018-12-12T00: 00Z
source share