[issue27576] An unexpected difference between dict and OrderedDict

2016-09-09 Thread Eric Snow

Changes by Eric Snow :


--
resolution:  -> fixed
stage: needs patch -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27576] An unexpected difference between dict and OrderedDict

2016-09-09 Thread Eric Snow

Eric Snow added the comment:

Thanks for pointing this out, Alexander.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27576] An unexpected difference between dict and OrderedDict

2016-09-09 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 70758c12e888 by Eric Snow in branch 'default':
Issue #27576: Fix call order in OrderedDict.__init__().
https://hg.python.org/cpython/rev/70758c12e888

--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27576] An unexpected difference between dict and OrderedDict

2016-07-30 Thread Xiang Zhang

Xiang Zhang added the comment:

After totally studying OrderedDict, I get a better understanding of what Serhiy 
means. So although we can get a better performance for dict, it's not needed at 
all. Remove the v3 patch.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27576] An unexpected difference between dict and OrderedDict

2016-07-30 Thread Xiang Zhang

Changes by Xiang Zhang :


Removed file: http://bugs.python.org/file43902/odict_update_v3.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27576] An unexpected difference between dict and OrderedDict

2016-07-26 Thread Xiang Zhang

Xiang Zhang added the comment:

I write a new version restoring the fast path for dict. It now uses PyDict_Next 
and seems to be much faster than the path using keys.

[cpython]$ ./python -m timeit -s 'from collections import OrderedDict; d = 
{"a":1,"c":2,"b":3,"d":4}' 'OrderedDict(d)'
100 loops, best of 3: 0.639 usec per loop
[cpython]$ ./python -m timeit -s 'from collections import OrderedDict; d = 
{"a":1,"c":2,"b":3,"d":4}' 'OrderedDict(d)'
100 loops, best of 3: 0.372 usec per loop

--
Added file: http://bugs.python.org/file43902/odict_update_v3.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27576] An unexpected difference between dict and OrderedDict

2016-07-25 Thread Xiang Zhang

Xiang Zhang added the comment:

I didn't think about order. I just thought using concrete API may be faster. 
But after your comment, I tested the performance and it seems PyDict_Items 
makes it much slower (it does more work, eg, make tuples). So I agree it is not 
needed at all.

--
Added file: http://bugs.python.org/file43879/odict_update_v2.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27576] An unexpected difference between dict and OrderedDict

2016-07-25 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I think this case (fast path for exact dict) is not needed at all. Exact dict 
is not ordered, and OrderedDict created from exact dict has nondetermined order 
(unless a dict has size 0 or 1).

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27576] An unexpected difference between dict and OrderedDict

2016-07-25 Thread Xiang Zhang

Xiang Zhang added the comment:

Submit a patch to fix this. Hope it helps.

--
keywords: +patch
nosy: +xiang.zhang
Added file: http://bugs.python.org/file43876/odict_update.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27576] An unexpected difference between dict and OrderedDict

2016-07-20 Thread Alakshendra Yadav

Changes by Alakshendra Yadav :


--
nosy: +alakyadav

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27576] An unexpected difference between dict and OrderedDict

2016-07-19 Thread Raymond Hettinger

Raymond Hettinger added the comment:

This does need to be fixed.  

FWIW, here is the relevant docstring from MutableMapping:
''' D.update([E, ]**F) -> None.  Update D from mapping/iterable E and F.
If E present and has a .keys() method, does: for k in E: D[k] = 
E[k]
If E present and lacks .keys() method, does: for (k, v) in E: 
D[k] = v
In either case, this is followed by: for k, v in F.items(): D[k] = v
'''

--
nosy: +rhettinger

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27576] An unexpected difference between dict and OrderedDict

2016-07-19 Thread Emanuel Barry

Changes by Emanuel Barry :


--
assignee:  -> eric.snow
components: +Library (Lib)
keywords: +3.5regression -3.4regression
nosy: +ebarry, eric.snow
stage:  -> needs patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27576] An unexpected difference between dict and OrderedDict

2016-07-19 Thread Alexander Belopolsky

New submission from Alexander Belopolsky:

Consider the following code:

$ cat x.py
from collections import OrderedDict
class X:
def items(self):
print('items')
return []
def keys(self):
print('keys')
return []

print(dict(X()))
print(OrderedDict(X()))

When I run it under python 3.4, I get

$ python3.4 x.py
keys
{}
keys
OrderedDict()

but under python 3.5, I get

$ python3.5 x.py
keys
{}
items
OrderedDict()


Under 3.4 both dict and OrderedDict constructors call the keys() method of the 
underlying object (and then call __getitem__ repeatedly if keys() returns a 
non-empty list), but in 3.5 OrderedDict behavior changed and it calls the 
values() method instead.

--
keywords: 3.4regression
messages: 270842
nosy: belopolsky
priority: normal
severity: normal
status: open
title: An unexpected difference between dict and OrderedDict
type: behavior
versions: Python 3.5

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com