BufferingHandler's documentatio says "Initializes the handler with a buffer of the specified capacity." but it does not specify what capacity means. One would assume the intention is to give a bound to memory usage, and that capacity is bytes. Looking at the source instead, the check is: return (len(self.buffer) >= self.capacity) and self.buffer is initialised with an empty list, so capacity is a number of lines, which cannot be used to constrain memory usage, and for which I struggle to see a use case. I believe that the current behaviour is counterintuitive enough to deserve, if not changing, at least documenting
Python isn't a low-level language, and there isn't *in general* a particular intention "to give a bound to memory usage". When using "buffer" in a general sense, rather than a buffer object (which is more akin to a byte-array), it's usually understood to mean a Python list (used as an array) and the capacity refers to the number of elements. You may struggle to see a use case for specifying a buffer capacity as a number of elements rather than a byte size, but that doesn't mean that such use cases don't exist. Are you perhaps using MicroPython in a constrained-memory environment? In the 17 years that this code has been in Python, it's the first time AFAIK that anyone has raised the term "capacity" as potentially confusing, so I don't think such confusion is common. However, I'll be happy to update the documentation to clarify that "capacity" means "number of records buffered".