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

new readbytes and readbytes! functions #3878

Merged
merged 1 commit into from
Jul 30, 2013
Merged

Conversation

stevengj
Copy link
Member

This pull request expands the functionality of the (internal) readbytes functions that we already had into two new (exported & documented) functions (inspired by the functionality in Python's RawIOBase class):

readbytes!(stream, buffer::Vector{Uint8}, nb=length(buffer))
readbytes(stream, nb=typemax(Int))

The readbytes! function reads up to nb bytes into buffer (growing it as needed), returning the number of bytes read. The readbytes function reads up to nb bytes and returns a new Vector{Uint8} buffer containing the bytes read.

(Incidentally, we had two different implementations of readall(s::IO), one replacing the other; I kept the one that uses readbytes.)

PS. I added this functionality to make it easier for PyCall to pass Julia IO objects as the corresponding types in Python.

stevengj added a commit to JuliaPy/PyCall.jl that referenced this pull request Jul 30, 2013
Keno added a commit that referenced this pull request Jul 30, 2013
new readbytes and readbytes! functions
@Keno Keno merged commit f68dac1 into JuliaLang:master Jul 30, 2013
@stevengj stevengj mentioned this pull request Aug 2, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants