Skip to content

Implement buffered io streams (io.TextIOWrapper and friends) #726

@pfalcon

Description

@pfalcon

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions