Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a buffered stream interface #7

Open
alaviss opened this issue Feb 4, 2021 · 1 comment
Open

Add a buffered stream interface #7

alaviss opened this issue Feb 4, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@alaviss
Copy link
Owner

alaviss commented Feb 4, 2021

Currently files only provide low-level read/write primitives. These are not buffered, so convenience like readLine are not available.

Goals:

  • Pluggable buffering interface, basically so that any Stream can be plugged into BufferedStream and receive all the perks.
@alaviss alaviss added the enhancement New feature or request label Feb 4, 2021
@c-blake
Copy link

c-blake commented Aug 3, 2021

You probably want to at least look at the POSIX getline/getdelim API. The reason is so that the control flow for the hot path can be "read buffer, memchr(..delim), maybe read more, ...". Doing this correctly can get you within around 1.25 .. 1.5x of memory mapped IO (which uses just the memchr part).

EDIT: you likely already know, but while this is a good thing to have, one of the downsides of this is that any FFI called/client code will not be able to "just use" the same "stdin/out/err" File objects, but will have to use your mirror of them for buffering to be coherent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants