[Python-ideas] Fwd: collections.Counter should implement fromkeys

Tim Peters tim.peters at gmail.com
Sat Jun 30 03:44:34 EDT 2018


[Abe Dillon]
> I haven't been part of the conversation for 15 years, but most of the
argument
> against the idea (yours especially) seem to focus on the prospect of a
> constructor war and imply that was the original motivation behind actively
> disabling the fromkeys method in Counters.

I quoted the source code verbatim - its comment said fromkeys() didn't make
sense for Counters.  From which it's an easy inference that it makes more
than one _kind_ of sense, hence "constructor wars".  Not that it matters.

Giving some of the history was more a matter of giving a plausible reason
for why you weren't getting all that much feedback:  it's quite possible
that most readers of this list didn't even remember that `dict.fromkeys()`
is a thing.

> I don't mean to give the impression that I'm fanatical about this. It
really
> is a minor inconvenience. It doesn't irk me nearly as much as other minor
> things, like that the fact that all the functions in the heapq package
begin
> with the redundant word 'heap'.

You have to blame Guido for that one, which is even more futile than
arguing with Raymond ;-)  It never much bothered me, but I do recall doing
this once:

from heapq import heappush as push, heappop as pop # etc


>> Raymond may have a different judgment about that, though.  I don't
believe
>> he reads python-ideas anymore

> He actually did reply a few comments back!

Ya, I saw that!  He's always trying to make me look bad ;-)

> I think I'm having more fun chatting with people that I deeply respect
> than "jumping up and down". I'm sorry if I'm coming off as an asshole.

Not at all!  I've enjoyed your messages.  They have tended to more on the
side of forceful advocacy than questioning, though, which may grate after a
few more years.  As to my "jumping up and down", I do a lot of
leg-pulling.  I'm old.  It's not meant to offend, but I'm too old to care
if it does :-)

> We can kill this thread if everyone thinks I'm wasting their time. It
doesn't
> look like anyone else shares my minor annoyance. Thanks for indulging me!

Raymond's reply didn't leave any hope for adding Counter.fromkeys(), so in
the absence of a killer argument that hasn't yet been made, ya, it would be
prudent to move on.

Unless people want to keep talking about it, knowing that Raymond won't buy
it in the end.  Decisions, decisions ;-)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180630/a41c37a2/attachment-0001.html>


More information about the Python-ideas mailing list