-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
Description
Doing I/O (well, at least input) with multibyte characters (like UTF-8) requires buffering support (because if have bytes not forming a complete character, they cannot be passed to the application, buy yet we already have them, and need to store somewhere in the interim - in the buffer).
With this blocking need for input buffering to implement unicode text streams, Python "io" module actually defines buffered streams for binary data either, and buffered streams are used by default.
General buffering support is contradictory question. On one hand, uPy is intended to be light and unbloated, so buffering is rather left to underlying layers, like OS. But then one big usecase for uPy is baremetal, where no OS exists. But then it's particular driver's job to do the buffering, because disk/network drivers need to do it anyway. But that buffering is very likely the minimal required to accommodate hardware requirements, not giving the best performance (which is the main reason for application-level buffering).
Summing up, it makes sense to implement just generic I/O buffering in uPy, and give people choice to use it, while setting reasonable defaults.