Skip to content

BitArray I/O is awkward #11940

@quinnj

Description

@quinnj
b = falses(1)
file = tempname()
open(file,"w") do f
    write(f,b)
end
filesize(file) == 8

So the length of the original BitArray is lost in I/O.

Not sure we can really do anything about this since we can't (I think) write a single bit to a file, but this can be a bit surprising.

I wonder though if this calls for a Bit type that would be the eltype(::BitArray). That would at least allow you to do

b = read(io, Bit, 1)

I'm pretty sure this has been discussed elsewhere, so I'll try to dig around to see what was or if there was anything concluded. Feel free to close if this is old news.

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