-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
write(to::IO, from::IO) #14628
Labels
io
Involving the I/O subsystem: libuv, read, write, etc.
Comments
I agree |
+1 |
Included in #14660 |
Ah, thank you - I was thinking about this just last night while writing from one stream to another. It seemed odd to me that this method didn't already exist. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have some code like this:
With
write(to::IO, from::IO)
it could be reduced to:This is not just about terse code.
The
write(readavailable())
loop is potentially quite memory inefficient. If the task has been suspended for a while, the stream could have many MB available and depending on how stream buffering is implemented large buffers could be duplicated.It seems like it would be better to have a
write(to::IO, from::IO)
API so that shortcut implementations can be created to directly connect two streams at a low level where that is more efficient.e.g. this could map to
sendfile()
in some cases.The default can just be:
The text was updated successfully, but these errors were encountered: