10đź‘Ť
Based on user1474837’s helpful link to the Django ticket on this question, it seems clear that tuples are used for backwards compatibility with the way settings were done from the start, which was with tuples due to the belief they were faster than lists. (They are, but only very slightly, according to data cited in the ticket discussion.)
Specifically, Django docs used to say:
For settings that are sequences, use tuples instead of lists. This is purely for performance.
Later in the discussion, a Django core developer notes:
We’re certainly not about to move from tuples to lists there because it would break existing code that already expects things to be tuples. I’ll remove the performance note, however, since it’s not worth scaring people.
Note the word “purely” in the original documentation — which if taken at face value would mean indicating settings are immutable is not a reason tuples are used. Also note someone in the ticket discussion references settings as “sort of” immutable, so it’s not even clear settings are in fact immutable.
P.S. For interest, note the ticket resolution ends with:
Changed the “write your own settings” recommendation to mention that Django
uses tuples, but not making it a recommendation. That might head off the endless
tuples vs. lists debates.
14đź‘Ť
This was changed in Django 1.9:
Default settings that were tuples are now lists
The default settings in django.conf.global_settings were a combination of lists and tuples. All settings that were formerly tuples are now lists.
https://docs.djangoproject.com/en/1.9/releases/1.9/#default-settings-that-were-tuples-are-now-lists
- Celery workers unable to connect to redis on docker instances
- Registered models do not show up in admin
- Change default Django REST Framework home page title
2đź‘Ť
I think the part of reason is tuple is read-only which will more safe and more suitable for setting.
- Add functionality to Django FlatPages without changing the original Django App
- Google.maps.event.addDomListener() is deprecated, use the standard addEventListener() method instead : Google Place autocomplete Error
- Performance, load and stress testing in Django
- How can i get all models in django 1.8