-
-
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
Document/export copy-free string allocation? #19945
Comments
At some point, @JeffBezanson said in #19945 that something like |
BTW, am I right that |
@nalimilan, no, that does not typically make a copy, because |
|
Would it be bad to make this the default for all byte arrays? |
To the extent possible, if we're going to export some of these interfaces, I'd like to put some thought into making sure that they're future proof in the sense that the same API will continue to be usable even if we change the underlying string implementation. The |
Any more thoughts on this? It is a very convenient API, and is currently used by HDF5.jl |
It's used in CSTParser.jl, CSV.jl, DelimitedFiles.jl, ExactConvolution.jl, Format.jl, GraphQLParser.jl, HDF5.jl, HTTP.jl, JSON2.jl, JSON3.jl, JuliaSyntax.jl, LazyJSON.jl, MySQL.jl, Parsers.jl, Pidfile.jl, ShortStrings.jl, SourceWalk.jl, StrBase.jl, StringViews.jl, and ZMQ.jl … |
There are now (as of #19449) undocumented functions
Base._string_n(n)
(to allocate ann
-byte string) andBase.StringVector(n)
(to allocate ann
-byte array that can be converted to a string without copying). Should some version of these be documented and exported? They seem useful for e.g. string processing and calling C APIs expecting pre-allocated string buffers.Note also that the
String(v::Vector{UInt8})
documentation, which says that it takes "ownership" of the array, seems to be wrong now (unlessv
was allocated withStringVector
).cc @JeffBezanson, @nalimilan
The text was updated successfully, but these errors were encountered: