[Python-ideas] Pre-PEP: adding a statistics module to Python
Steven D'Aprano
steve at pearwood.info
Sun Aug 4 03:51:49 CEST 2013
On 04/08/13 05:47, Alexander Belopolsky wrote:
> The PEP does not mention statistics.sum(), but the reference implementation
> includes it. I am not sure stdlib needs the third sum function after
> builtins.sum and math.fsum. I think it will be better to improve
> builtins.sum instead.
I don't know enough C to volunteer to do that. If the built-in sum() is improved to the point it passes my unit tests, I would consider using it in the future. However, it is traditional to expose a sum() function under Stats in scientific calculators, and I think that whether I use my own, or the built-in, the statistics module should continue to expose it as a public function.
For the same reason, I'm very slightly +0.01 leaning towards adding a sum2 function for calculating the sum of squares, but on the other hand it is simple enough to do with a generator expression:
sum(x**2 for x in data)
so I thought I'd leave it out and see if there is demand for it.
--
Steven
More information about the Python-ideas
mailing list