Potential bottlenecks when using `logging.handlers.BufferingHandler`


I was trying to use python logging module in batch fashion and I came across logging.handlers.BufferingHandler. I read through the code and found that the buffer is using list as its type. However, if the capacity is large (say 1000), it’ll potentially block the program (since it needs to be constantly reallocated).

Do we have any way to get around this? (I thought of pre-allocated the list but the array module only works with numeric datatypes)

Its relatively cheap to grow a list. And 1000 is not large, its small.
Also I do not think that the implentation of list grow 1 by 1 I think its in chunks.
I would expect the formattting of the log record to be a lot more expensive.

Unless you see a actual performance issue with your code I would not worry about this detail.

See this comment in the C Python source code that confirms this: cpython/Objects/listobject.c at main · python/cpython · GitHub