Raymond Hettinger added the comment:

Some of these were Guido's design decisions made over a decade ago.  He 
explicitly choose not have the spelled-out method names (both here in the 
concrete class and in the corresponding abstract base classes).  It usually 
isn't a good idea to second guess his long standing decisions which have worked 
out well in practice.

>From my own point-of-view, I prefer not to use the set curly brace notation in 
>the repr for several reasons.

1) Ideally, the reprs for the keys(), values(), and items() should all have a 
similar look.   The list notation is equally applicable to all of three, but 
the set notation isn't applicable to the values() which can have duplicates and 
may have non-hashable values.

2) The keys(), values(), and items() are guaranteed to be in the same order.  
The list notation reinforces this fact while the set notation does not.

3) There may be unforeseen usability issues (perhaps the change might falsely 
imply that there is an underlying set rather than a view of the dict, or 
perhaps it would imply that the full set() API is supported which it is not).

4) In Python 2, all three methods actually returned lists even though it would 
have been possible to return a set() for the keys.  Though it isn't required, I 
do like the continuity in thought between the versions.

----------
components: +Interpreter Core
nosy: +rhettinger

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue31563>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to