[Python-ideas] Running average and stdev in the statistics module?

Serge Matveenko s at matveenko.ru
Sun May 12 19:53:27 EDT 2019

On Fri, May 10, 2019 at 2:33 PM Steven D'Aprano <steve at pearwood.info> wrote:
> On Mon, May 06, 2019 at 08:10:44PM +0300, Serge Matveenko wrote:
> > Personally, I would definitely use this in a number of places in the
> > real-life code I contribute to.
> >
> > The problem that I have with this idea is it's not clear how to store
> > the data in an accumulator class. What about cases with different
> > contexts in asyncio and/or multithreading code?
> Can you give an example of the sort of thing you might want to do?

Something like storing a running metric of the code in a kinda
multithreaded environment is a common thing to do. Say, it could be a
metric of an execution duration of a function which could be accessed
from within a Flask app and/or from within celery tasks. This couldn't
be achieved using in-memory storage as web server has its own isolated
memory, as well as each celery worker has. So, I would like to
implement my own storage for this data, e.g. using Redis.

More information about the Python-ideas mailing list