Skip to content

Conversation

@nickrobinson251
Copy link
Contributor

Ryu.writeshortest is documented to have a method that "allows passing in a byte buffer", just like Ryu.writefixed and Ryu.writeexp, but unlike those functions writeshortest is type constrained to ::Vector{UInt8}. This PR loosens that to ::AbstractVector{UInt8}, to allow the "byte buffer" to e.g. be a Memory rather than a Vector.

I've added tests and updated the docstrings for all three functions to ensure that they're not just restricted to Vector{UInt8}.

This change was prompted by our private codebase hitting MethodError: no method matching writeshortest(::Memory{UInt8}, ::Int64, ::Float64, ...) when trying it out with Julia v1.12.0-DEV.

(cc @quinnj -- i think you added this method originally, but i couldn't see any reason why e.g. Memory shouldn't be allowed now we have it)

Copy link
Member

@quinnj quinnj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, great change. This was all pre-Memory, and Vector{UInt8} was really the only low-level efficient blob thing, so this is a good update.

@nickrobinson251
Copy link
Contributor Author

CI failures look unrelated

@quinnj quinnj merged commit 8560318 into JuliaLang:master Jan 28, 2025
5 of 7 checks passed
@nickrobinson251
Copy link
Contributor Author

Thanks, Jacob!

@nickrobinson251 nickrobinson251 deleted the npr-ryu-loosen-type-constraint branch January 28, 2025 17:04
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.

3 participants