-
-
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
implement reinterpret using jl_reshape_array #232
Comments
Here's a non-obvious issue: I currently allocate all byte arrays with a hidden extra 0 at the end so they can be passed to C as strings without worrying about it. If an array is reinterpreted in place to a byte array, that 0 won't be there. |
Good call. That would certainly be a subtle nasty bug at some point. Two possibly options I can think of:
For the latter, the way that makes the most sense to me is that when an array of bytes is "given" to a byte string (ASCII or UTF-8) we grow the array by one byte which is set to zero and then the length of the string object is one less than its data buffer. This has the advantage of not adding extra overhead to all byte arrays and being far less magical than what we have now. |
The downside, of course is that it doesn't address actual |
This would actually be breaking since it changes the semantics of |
I think it's pretty important NOT to name this |
How should we handle the trailing NUL thing? |
We should probably just put a zero at the end of all arrays, that's simplest. |
Ok, I'm changing my mind now. That extra byte will require an extra word, which is really not ok for small arrays. Plus, reinterpreting a non-byte array to a byte array and then using it as a string is an extremely strange thing to do. Indeed I can't think of a single use case for that. We might just have to document that only arrays originally allocated as byte arrays have the extra 0. |
…1061ecc (#55615) Stdlib: Downloads URL: https://github.com/JuliaLang/Downloads.jl.git Stdlib branch: master Julia branch: backports-release-1.11 Old commit: a9d274f New commit: 1061ecc Julia version: 1.11.0-rc2 Downloads version: 1.6.0(It's okay that it doesn't match) Bump invoked by: @IanButterworth Powered by: [BumpStdlibs.jl](https://github.com/JuliaLang/BumpStdlibs.jl) Diff: JuliaLang/Downloads.jl@a9d274f...1061ecc ``` $ git log --oneline a9d274f..1061ecc 1061ecc Fix setting atexit. Fixes trailing download tasks during precompilation (#257) b871386 Add debug information to `setopt` commands (#248) 51e5321 fix: use invokelatest for easy_hook, avoid race (#241) 05f9ec2 make precompile workload relocatable (#236) 2dd891a Hardcode doc edit backlink (#232) ``` Co-authored-by: Dilum Aluthge <[email protected]>
This should as a side-effect allow the result array to share memory with the argument array.
The text was updated successfully, but these errors were encountered: