I don't have strong feelings, but I would say yes to __imul__, no to
__div__ and __floordiv__ (with str/list/tuple as the precedent).

For chisquare, I would be perfectly happy with:

digit_counts = Counter(...)
scipy.stats.chisquare(list(digit_counts.values()))

On Sun, Apr 15, 2018 at 9:39 PM Raymond Hettinger <
raymond.hettin...@gmail.com> wrote:

>
>
> > On Apr 15, 2018, at 9:04 PM, Peter Norvig <pe...@norvig.com> wrote:
> >
> > it would be a bit weird and disorienting for the arithmetic operators to
> have two different signatures:
> >
> >     <counter> += <counter>
> >     <counter> -= <counter>
> >     <counter> *= <scalar>
> >     <counter> /= <scalar>
> >
> > Is it weird and disorienting to have:
> >
> > <str> += <str>
> > <str> *= <scalar>
>
> Yes, there is a precedent that does seem to have worked out well in
> practice :-)  It isn't exactly parallel because strings aren't containers
> of numbers, they don't have & and |, and there isn't a reason to want a /
> operation, but it does suggest that signature variation might not be
> problematic.
>
> BTW, do you just want __mul__ and __rmul__?  If those went in, presumably
> there will be a request to support __imul__ because otherwise c*=3 would
> still work but would be inefficient (that was the rationale for adding
> inplace variants for all the current arithmetic operators). Likewise,
> presumably someone would legitimately want __div__ to support the
> normalization use case.  Perhaps less likely, there would be also be a
> request for __floordiv__ to allow exactly scaled results to stay in the
> domain of integers.  Which if any of these makes sense to you?
>
> Also, any thoughts on the cleanest way to express the computation of a
> chi-squared statistic (for example, to compare observed first digit
> frequencies to the frequencies predicted by Benford's Law)?  This isn't an
> arbitrary question (it came up when a professor first proposed a variant of
> this idea a few years ago).
>
>
> Raymond
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to