In Julia, I want to do this with BitArrays instead to save even more space, but cannot find suitable methods to do so. We do have Serialization.serialize and JLD2.jl, but they don’t do quite the same thing. The numpy functions work specifically on arrays and allow us to specify the dtype, eliminating the need of serialization headers. The Julia methods doesn’t provide this convenience.
Are there standard library functions or specific packages I missed that could replace the numpy functions? Or would I have to write the functions myself? Thanks!
But you can also just call write(io, array) to write the raw bytes without calling reinterpret, so I’m a little confused about what you are trying to do.
reinterpret won’t do what you want with a BitArray. The raw storage bytes (which are the bits packed into 64-bit chunks are in somebitarray.chunks:
I knew about reinterpret and BitArray.chunks, but I finally figured that probably the actual problem in my case is that Julia doesn’t seem have a bytes type, which is built into Python (is IOBuffer similar to that?). And I don’t like the idea of storing the results as a BigInt either. To make things clearer, what I wanted to do is storing raw bytes from BitVector.chunks without header (which would be too large since the arrays themselves I’m using wouldn’t be large) as SQLite values, and be able to read that back into a BitVector. JLD2.jl could technically replace SQLite, but the gigantic overhead of metadata is unbearable in my case.
The analogue is just Vector{UInt8} (though this is mutable so it is closer to bytearray in Python). (IOBuffer is a wrapper around this that you can read or write with.)
BigInt is totally the wrong type for storing arbitrary byte sequences.