Re: [Python-Dev] How about updating OrderedDict in csv and configparser to regular dict?

2019-01-31 Thread INADA Naoki
I'm sorry, configparser is changed already.
https://bugs.python.org/issue33504

On Thu, Jan 31, 2019 at 4:52 PM INADA Naoki  wrote:
>
> Hi,
>
> csv.DictReader uses OrderedDict by default, from Python 3.6.
> But it doesn't make sense anymore, like namedtuple._asdict().
> How about changing default dict type back to regular dict.
>
> Python is widely used for handling learge data.  So I think
> changing default dict type to OrderedDict was performance
> and memory usage regression in 3.6.
>
> Additionally, configparser uses OrderedDict by default from Python 3.6 too.
>
> I am not sure about `parser['section1'] == parser['section2']` is not used 
> yet.
> But we broke it once in 3.6 by changing dict to OrderedDict.  Are there any
> issue report caused by this backward incompatibility?
>
> And I think performance and memory efficiency is not so important for
> configparser, unlike csv.
>
> I'm
>
> * +1 about changing csv.DictReader's default dict type
> * +0.5 about changing configparser's default dict type.
>
> How do you think?
>
> Regards,
> --
> INADA Naoki  



-- 
INADA Naoki  
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] How about updating OrderedDict in csv and configparser to regular dict?

2019-01-31 Thread Michael Selik
Waiting on review
https://github.com/python/cpython/pull/8014

On Thu, Jan 31, 2019, 12:04 AM INADA Naoki  I'm sorry, configparser is changed already.
> https://bugs.python.org/issue33504
>
> On Thu, Jan 31, 2019 at 4:52 PM INADA Naoki 
> wrote:
> >
> > Hi,
> >
> > csv.DictReader uses OrderedDict by default, from Python 3.6.
> > But it doesn't make sense anymore, like namedtuple._asdict().
> > How about changing default dict type back to regular dict.
> >
> > Python is widely used for handling learge data.  So I think
> > changing default dict type to OrderedDict was performance
> > and memory usage regression in 3.6.
> >
> > Additionally, configparser uses OrderedDict by default from Python 3.6
> too.
> >
> > I am not sure about `parser['section1'] == parser['section2']` is not
> used yet.
> > But we broke it once in 3.6 by changing dict to OrderedDict.  Are there
> any
> > issue report caused by this backward incompatibility?
> >
> > And I think performance and memory efficiency is not so important for
> > configparser, unlike csv.
> >
> > I'm
> >
> > * +1 about changing csv.DictReader's default dict type
> > * +0.5 about changing configparser's default dict type.
> >
> > How do you think?
> >
> > Regards,
> > --
> > INADA Naoki  
>
>
>
> --
> INADA Naoki  
> ___
> Python-Dev mailing list
> Python-Dev@python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> https://mail.python.org/mailman/options/python-dev/mike%40selik.org
>
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] How to update namedtuple asdict() to use dict instead of OrderedDict

2019-01-31 Thread Antoine Pitrou
On Wed, 30 Jan 2019 14:32:38 -0800
Raymond Hettinger  wrote:
> 
> My recommendation is Option 4 as being less disruptive and more beneficial 
> than the other options.

Option 4 here as well.  Sometimes perfection is the enemy of the good.

Regards

Antoine.


___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] How about updating OrderedDict in csv and configparser to regular dict?

2019-01-31 Thread Steve Holden
I submitted the patch to make the csv module use an OrderedDict in
DictReader. It doesn't, AFAIR, use anything but the ordering property of
ordered dict, so the reversion to a simple dict should be perfectly OK as
long as no consumers have started to make use of specific OrderedDict
properties.

regards
Steve Holden


On Thu, Jan 31, 2019 at 7:55 AM INADA Naoki  wrote:

> Hi,
>
> csv.DictReader uses OrderedDict by default, from Python 3.6.
> But it doesn't make sense anymore, like namedtuple._asdict().
> How about changing default dict type back to regular dict.
>
> Python is widely used for handling learge data.  So I think
> changing default dict type to OrderedDict was performance
> and memory usage regression in 3.6.
>
> Additionally, configparser uses OrderedDict by default from Python 3.6 too.
>
> I am not sure about `parser['section1'] == parser['section2']` is not used
> yet.
> But we broke it once in 3.6 by changing dict to OrderedDict.  Are there any
> issue report caused by this backward incompatibility?
>
> And I think performance and memory efficiency is not so important for
> configparser, unlike csv.
>
> I'm
>
> * +1 about changing csv.DictReader's default dict type
> * +0.5 about changing configparser's default dict type.
>
> How do you think?
>
> Regards,
> --
> INADA Naoki  
> ___
> Python-Dev mailing list
> Python-Dev@python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> https://mail.python.org/mailman/options/python-dev/steve%40holdenweb.com
>
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] Fwd: How about updating OrderedDict in csv and configparser to regular dict?

2019-01-31 Thread Steve Holden
-- Forwarded message -
From: Steve Holden 
Date: Thu, Jan 31, 2019 at 11:05 AM
Subject: Re: [Python-Dev] How about updating OrderedDict in csv and
configparser to regular dict?
To: INADA Naoki 


And I see that such a patch is now merged. Thanks,  Raymond!

>
>>
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Add more SyntaxWarnings?

2019-01-31 Thread Nick Coghlan
On Thu, 31 Jan 2019 at 04:16, Stefan Behnel  wrote:
> I faintly recall someone implementing something in that direction. It's
> probably in some package on PyPI.

You may be thinking of Doug Hellman's https://pypi.org/project/whatthewhat/

Cheers,
Nick.

P.S. More horrifyingly (in an amusing way), there's also
https://github.com/drathier/stack-overflow-import

-- 
Nick Coghlan   |   ncogh...@gmail.com   |   Brisbane, Australia
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] How to update namedtuple asdict() to use dict instead of OrderedDict

2019-01-31 Thread Nick Coghlan
On Thu, 31 Jan 2019 at 16:40, Glenn Linderman  wrote:
>> On 1/30/2019 8:45 PM, Raymond Hettinger wrote:
>>> On Jan 30, 2019, at 3:41 PM, Glenn Linderman  wrote:
>>> Would it be practical to add deprecated methods to regular dict for the 
>>> OrderedDict reordering methods that raise with an error suggesting "To use 
>>> this method, convert dict to OrderedDict." (or some better wording).
>> That's an interesting idea.  Regular dicts aren't well suited to the 
>> reordering operations (like lists, repeated inserts at the front of the 
>> sequence wouldn't be performant relative to OrderedDict which uses 
>> double-linked lists internally).  My instinct is to leave regular dicts 
>> alone so that they can focus on their primary task (being good a fast 
>> lookups).
> My goal was just to give a meaningful error message if someone misses the 
> implications in What's New, and has code that actually does expect 
> named_tuple.as_dict to have the ordering operations.

The downside of doing that is that automated code introspection tools
don't know that the methods don't really exist, they just see the
method names in the type dictionary and offer them up for code
completion.

So in this case, the extra runtime check isn't worth the cost of
breaking static code analysis and other forms of introspection.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncogh...@gmail.com   |   Brisbane, Australia
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Fwd: How about updating OrderedDict in csv and configparser to regular dict?

2019-01-31 Thread Raymond Hettinger



> On Jan 31, 2019, at 3:06 AM, Steve Holden  wrote:
> 
> And I see that such a patch is now merged. Thanks,  Raymond!

And thank you for getting ordering into csv.DictReader.  That was a significant 
improvement in usability :-)


Raymond
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] How to update namedtuple asdict() to use dict instead of OrderedDict

2019-01-31 Thread Nathaniel Smith
On Thu, Jan 31, 2019, 05:26 Nick Coghlan  On Thu, 31 Jan 2019 at 16:40, Glenn Linderman 
> wrote:
> >> On 1/30/2019 8:45 PM, Raymond Hettinger wrote:
> >>> On Jan 30, 2019, at 3:41 PM, Glenn Linderman 
> wrote:
> >>> Would it be practical to add deprecated methods to regular dict for
> the OrderedDict reordering methods that raise with an error suggesting "To
> use this method, convert dict to OrderedDict." (or some better wording).
> >> That's an interesting idea.  Regular dicts aren't well suited to the
> reordering operations (like lists, repeated inserts at the front of the
> sequence wouldn't be performant relative to OrderedDict which uses
> double-linked lists internally).  My instinct is to leave regular dicts
> alone so that they can focus on their primary task (being good a fast
> lookups).
> > My goal was just to give a meaningful error message if someone misses
> the implications in What's New, and has code that actually does expect
> named_tuple.as_dict to have the ordering operations.
>
> The downside of doing that is that automated code introspection tools
> don't know that the methods don't really exist, they just see the
> method names in the type dictionary and offer them up for code
> completion.
>
> So in this case, the extra runtime check isn't worth the cost of
> breaking static code analysis and other forms of introspection.
>

It's technically possible for attributes to do something custom when
accessed, without appearing in __dir__. I don't know if that's a useful
technique in this case, but sometimes it is.

-n
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com