Re: Settings: lists or tuples?

2015-02-19 Thread Tom Evans
On Thu, Jan 22, 2015 at 12:32 PM, Andreas Kahnert wrote: > Hi again, > Well, I can acknoledge that your reasons for list (beginner friendly) are as > good as my reasons for tuples (seems to be more logical choice for things > that are static). To say it in other words,

Re: Settings: lists or tuples?

2015-01-22 Thread Andreas Kahnert
Hi again, Well, I can acknoledge that your reasons for list (beginner friendly) are as good as my reasons for tuples (seems to be more logical choice for things that are static). To say it in other words, my idea was simply: Use tuples and the programmer will know that these arn't ment to be

Re: Settings: lists or tuples?

2015-01-21 Thread Aymeric Augustin
As explained above and discussed on the #django-dev IRC channel, it's an acceptable choice to use tuples, even though it isn't the default Django chose. Please don't raise warnings or do anything else to discourage using tuples. Writing this patch consists in: - going though the 22 settings

Re: Settings: lists or tuples?

2015-01-21 Thread Sambhav Satija
While I understand that turning it into a deprecation warning would be way out of bounds, That was simply meant to say that maybe we should raise *some* warning at startup time that'll ensure that the developer at least knows what he's up against if he puts in tuples instead of lists. On

Re: Settings: lists or tuples?

2015-01-21 Thread Tom Christie
> So, I've been working on a patch ... Suggestions? Normalizing on lists as the default throughout is good. Warning about using tuples and putting their usage on a deprecation path seems a little unnecessary. I don't think that was discussed in this thread, but I've only scanned through, so I

Re: Settings: lists or tuples?

2015-01-21 Thread Sambhav Satija
So, I've been working on a patch (PFA) . As being discussed, lists are easier for beginners to follow, and tuples provide a false sense of security. With that in mind, I've simply changed pretty much all the tuples in global_settings and template_settings to lists, and warn about the usage of

Re: Settings: lists or tuples?

2015-01-20 Thread Tom Christie
Hi Andreas, I'm completely in agreement with you that *in theory* using tuples would be a (very marginal) improvement. I also happen think that the idea that tuples are semantically different from simply being immutable lists is a nonsense - regardless of what a particular section of

Re: Settings: lists or tuples?

2015-01-20 Thread Aymeric Augustin
On 20 janv. 2015, at 18:52, Andreas Kahnert wrote: > But since you all seem to like lists that much, maybe a compromise would be > to explicitly note in the docs that there is a danger in using lists which > can be prevented by tuple usage. As explained in my

Re: Settings: lists or tuples?

2015-01-20 Thread Andreas Kahnert
Just for completness: accidential assignment to the settings object itself could be easily prevented with a __setattr__ method on its class, since django yields on various other places about configuration problems it could not be wrong if the programmer gets noted about an illegal assignment.

Re: Settings: lists or tuples?

2015-01-19 Thread Aymeric Augustin
On 19 janv. 2015, at 21:13, Andreas Kahnert wrote: > I advertise that strongly against lists, because we actually had that kind of > issue in our company. Hi Andreas, This is probably obvious, but I thought I’d mention it just in case — you can keep using tuples in

Re: Settings: lists or tuples?

2015-01-19 Thread Carl Meyer
its contract/documentation/docstring). Hopefully the second colleague in your anecdote learned that lesson. I don't see a reason here to prefer tuples over lists in settings. Carl -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to D

Re: Settings: lists or tuples?

2015-01-19 Thread Michael Manfre
The situation you described was definitely a learning experience for your company. Your strong opinion in favor of tuples is also noted. For the various reasons stated in this thread, I'm still +1 for lists. Regards, Michael Manfre On Mon, Jan 19, 2015 at 3:13 PM, Andreas Kahnert

Re: Settings: lists or tuples?

2015-01-19 Thread Andreas Kahnert
I advertise that strongly against lists, because we actually had that kind of issue in our company. One colleague created a list with phrases for some verbose logging in the settings.py. In the view function he promoted this list together with the actual data, also a list which is used for

Re: Settings: lists or tuples?

2015-01-19 Thread Andreas Kahnert
Interesting, ... so excuse me. The next point also clearifys my PS from above, lists are over-allocated dynamic sized arrays. (this explains why python is such an memory eater as well as why I experienced performance loss when using the mutability of lists extensivly) Am Montag, 19. Januar

Re: Settings: lists or tuples?

2015-01-19 Thread Loïc Bistuer
> On Jan 20, 2015, at 01:43, Andreas Kahnert wrote: > > Hi Loïc, > > I agree that we should not discuss about the theoretical aspects too much > (while I disagree on your distinction, the API difference is just their > mutability, so unless you refer to python

Re: Settings: lists or tuples?

2015-01-19 Thread Andreas Kahnert
Hi Loïc, I agree that we should not discuss about the theoretical aspects too much (while I disagree on your distinction, the API difference is just their mutability, so unless you refer to python intern algorithms for sort- /lookup- optimization (if so, excuse me) your distinction is just

Re: Settings: lists or tuples?

2015-01-19 Thread Loïc Bistuer
Hi Andreas, As Florian pointed out, you can't mutate a tuple, but you can mutate the settings object, so using a tuple or a frozendict won't buy you much. Regarding the theoretical perspective, tuples aren't meant to be immutable lists. Tuples are for heterogenous collections of fixed size

Re: Settings: lists or tuples?

2015-01-19 Thread Andreas Kahnert
PS: python should be able to access tuple members faster, because it can be implemented as array instead of double-linked-structs which are necessary mutable lists. But as far as I know it doesn't. -- You received this message because you are subscribed to the Google Groups "Django developers

Re: Settings: lists or tuples?

2015-01-19 Thread Andreas Kahnert
Well, yep. You can't prevent programmers to do stupid things in python. But I'm kind of a theroretician and it hurts me if I see that exactly that what it should not be is proposed as the standard. And for the dicts: In my private code-base I use a frozendict c-package I wrote. @Collin: The

Re: Settings: lists or tuples?

2015-01-19 Thread Florian Apolloner
On Monday, January 19, 2015 at 3:45:18 PM UTC+1, Andreas Kahnert wrote: > > I'm not talking about modifications inside the settings.py but in other > place. With lists, unexperienced devs might do things like: from > django.conf import settings; settings.TEMPLATE_DIRS[3] = '/my_tpls'; and >

Re: Settings: lists or tuples?

2015-01-19 Thread Collin Anderson
Hi Andreas, I agree that tuples do slightly help enforce that settings are supposed to be immutable, and I agree that if someone were to try to modify the settings the way you showed it would be very hard to debug. However, I think it's a pretty rare case. I think a much more common case is

Re: Settings: lists or tuples?

2015-01-19 Thread Andreas Kahnert
Test Code: old_var = settings.TEMPLATE_DIRS settings.TEMPLATE_DIRS += ('foo',) if isinstance(settings.TEMPLATE_DIRS, tuple) else ['foo'] old_var is settings.TEMPLATE_DIRS # will return True if it was a list; will return False if it was a tuple, since a new tuple was assigned to

Re: Settings: lists or tuples?

2015-01-19 Thread Marc Tamlyn
I think Florian's point would be that you can still do: from django.conf import settings settings.TEMPLATE_DIRS += ('foo',) if it is a tuple, so I don't really see how it being a tuple is making it necessarily more safe than a list - is the above code really much different to: from django.conf

Re: Settings: lists or tuples?

2015-01-19 Thread Andreas Kahnert
I'm not talking about modifications inside the settings.py but in other place. With lists, unexperienced devs might do things like: from django.conf import settings; settings.TEMPLATE_DIRS[3] = '/my_tpls'; and expect to work out good. (This doesn't violate the docs, since technicaly

Re: Settings: lists or tuples?

2015-01-19 Thread Florian Apolloner
On Monday, January 19, 2015 at 12:35:10 PM UTC+1, Andreas Kahnert wrote: > > I'm strongly against lists. Lists are mutable objects, their components > can be changed in place. The settings are initialized at server start and > after that changes on them arn't reflected. Therefore all settings

Re: Settings: lists or tuples?

2015-01-19 Thread Andreas Kahnert
Hi all, I'm strongly against lists. Lists are mutable objects, their components can be changed in place. The settings are initialized at server start and after that changes on them arn't reflected. Therefore all settings should be tuples from my point of view. Using a custom list/tuple class

Re: Settings: lists or tuples?

2015-01-16 Thread Collin Anderson
Hi All, Should change tuples to lists in more places in the docs? https://github.com/django/django/pull/3929 Collin On Thursday, December 18, 2014 at 7:56:47 AM UTC-5, Carl Meyer wrote: > > On 12/17/2014 11:49 PM, Russell Keith-Magee wrote: > > On Thu, Dec 18, 2014 at 7:48 AM, Carl Meyer

Re: Settings: lists or tuples?

2014-12-18 Thread Carl Meyer
On 12/17/2014 11:49 PM, Russell Keith-Magee wrote: > On Thu, Dec 18, 2014 at 7:48 AM, Carl Meyer wrote: >> This is clever, but on second thought I'm trying to figure out in what >> scenario a backwards-compatibility would actually occur here. In the >> context of a user's

Re: Settings: lists or tuples?

2014-12-17 Thread Ryan Hiebert
> On Dec 18, 2014, at 12:49 AM, Russell Keith-Magee > wrote: > > So - I retract my suggestion - I think I can live with just documenting this > as a backwards compatibility. Sounds good. In case anyone is interested, I made a pull request (not complete) with an

Re: Settings: lists or tuples?

2014-12-17 Thread Russell Keith-Magee
On Thu, Dec 18, 2014 at 7:48 AM, Carl Meyer wrote: > > On 12/17/2014 04:39 PM, Russell Keith-Magee wrote: > > On Thu, Dec 18, 2014 at 5:03 AM, Aymeric Augustin < > > aymeric.augus...@polytechnique.org> wrote: > > > >> On 17 déc. 2014, at 21:54, Carl Meyer

Re: Settings: lists or tuples?

2014-12-17 Thread Ryan Hiebert
e's no way we should have > a deprecation path just to switch some settings from tuples to lists. > > (I'm only in favor of it myself because I think in practice the impact > will be small.) Thanks for the warning, and your solution makes perfect sense to me. I’m gonna go ahead

Re: Settings: lists or tuples?

2014-12-17 Thread Carl Meyer
is all that's needed, even if they go and add to the resulting value several more times. If it's called with a list, it should behave as a normal list does. And before you get too far, you may want to wait and see if any other core devs step in to tell me I'm crazy and there's no way we should have a depre

Re: Settings: lists or tuples?

2014-12-17 Thread Ryan Hiebert
> On Dec 17, 2014, at 5:48 PM, Carl Meyer wrote: > > On 12/17/2014 04:39 PM, Russell Keith-Magee wrote: >> >> I agree that lists are preferable to tuples. >> >> One option for handling existing projects might be to define our own >> subclass of list that defines __add__,

Re: Settings: lists or tuples?

2014-12-17 Thread Carl Meyer
On 12/17/2014 04:39 PM, Russell Keith-Magee wrote: > On Thu, Dec 18, 2014 at 5:03 AM, Aymeric Augustin < > aymeric.augus...@polytechnique.org> wrote: > >> On 17 déc. 2014, at 21:54, Carl Meyer wrote: >> >>> So I think there is a backwards-compatibility issue. >> >> Indeed. >>

Re: Settings: lists or tuples?

2014-12-17 Thread Russell Keith-Magee
On Thu, Dec 18, 2014 at 5:03 AM, Aymeric Augustin < aymeric.augus...@polytechnique.org> wrote: > On 17 déc. 2014, at 21:54, Carl Meyer wrote: > > > So I think there is a backwards-compatibility issue. > > Indeed. > > > Personally, I would love to decide to just bite this bullet

Re: Settings: lists or tuples?

2014-12-17 Thread Andrea Corbellini
On Wed, Dec 17, 2014 at 9:48 PM, Aymeric Augustin wrote: Surprisingly, it seems that there isn’t a backwards compatibility problem with changing the type to lists, as the following pattern still works: # myproject/settings.py from

Re: Settings: lists or tuples?

2014-12-17 Thread Collin Anderson
I agree lists are the way to go. I have heard that tuples are faster, but I don't think that outweighs comma issue and inconsistency. global_settings isn't completely undocumented, based on greping the docs. Seems to me we should at least make the docs and project_template consistent and use

Re: Settings: lists or tuples?

2014-12-17 Thread Aymeric Augustin
On 17 déc. 2014, at 21:54, Carl Meyer wrote: > So I think there is a backwards-compatibility issue. Indeed. > Personally, I would love to decide to just bite this bullet and > normalize to lists, but I think it would need to be marked as a > backwards-incompatibility in the

Re: Settings: lists or tuples?

2014-12-17 Thread Michael Manfre
+1 for lists. On Wed, Dec 17, 2014 at 3:54 PM, Carl Meyer wrote: > > On 12/17/2014 01:48 PM, Aymeric Augustin wrote: > > I’m about to introduce a new setting that is a sequence of things, > TEMPLATES, and I have to decide whether it will be a tuple of a list. > > > >

Re: Settings: lists or tuples?

2014-12-17 Thread Carl Meyer
On 12/17/2014 01:48 PM, Aymeric Augustin wrote: > I’m about to introduce a new setting that is a sequence of things, TEMPLATES, > and I have to decide whether it will be a tuple of a list. > > Unfortunately Django is very inconsistent in the type of settings. In > global_settings.py: > > - 22

Settings: lists or tuples?

2014-12-17 Thread Aymeric Augustin
Hello, I’m about to introduce a new setting that is a sequence of things, TEMPLATES, and I have to decide whether it will be a tuple of a list. Unfortunately Django is very inconsistent in the type of settings. In global_settings.py: - 22 settings are tuples - 10 are empty, 12 aren't