← Back to Pull requests

add single-argument (de)serialize methods operating on vectors of bytes #60315

Open
aplavin opened this pull request with 34 lines diff across 2 files
View on GitHub
aplavin aplavin commented on Dec 04, 2025 20:17 UTC
Author

Basically, for convenience: I find myself copy-pasting these methods whenever I load/store Julia serialized data as part of another data format like parquet or sql database. They natively store byte arrays, and would be nice to have these (de)serialize methods going directly back and forth between Julia objects and byte vectors.

Another neat usecase is to quickly copy-paste a Julia object between different Julia sessions (repls, notebooks, remote, ...):

# in session 1:
x |> serialize |> base64encode
# copy the resulting string

# in session 2:
x = "<paste string here>" |> base64decode |> deserialize

Diff: 34 lines (+34 / -0) across 2 files Reviewer: JeffBezanson Review duration: 528486m
All Vouch review confidence checks passed
Residual risk 0.05 = Change Risk (0.33) × (1 − Review Confidence (0.84)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.33 · 34 lines diff across 2 files
0.33
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.80 · 5 substantive comment(s)
0.80
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
83%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.213
Real PR Conversation Timeline
11 items
JeffBezanson JeffBezanson approved these changes on Dec 05, 2025 20:10 UTC
Approved Reviewer

Approved these changes.

JeffBezanson JeffBezanson commented on Dec 05, 2025 20:12 UTC
Contributor

Looks good. Would be nice to add doc strings to these.

LilithHafner LilithHafner approved these changes on Dec 06, 2025 15:04 UTC
Approved Reviewer

LGTM. I've also wanted this functionality. There's no other plausible implementation of the deserialize(::Vector{UInt8}) method, and the return type Vector{UInt8} seems reasonable for the serialize(value) method.

Should go to triage as it is technically an expansion of public API? The specific question I'd ask is: "Is Vector{UInt8} the right return type for serialize(value)?"

JeffBezanson JeffBezanson commented on Dec 12, 2025 19:41 UTC
Contributor

I think we can just merge this. What is the mac build failure here about?

adienes adienes commented on Dec 12, 2025 19:53 UTC
Contributor

is there a reason the docs enforce specifically a Vector{UInt8} from serialize rather than an iterator over UInt8 ? it's quite rare one needs indexed access to serialized data, right?

for deserialize it makes sense to not promise more than is implemented, but I don't think these need to be perfectly symmetric

adienes adienes commented on code on Dec 12, 2025 20:04 UTC
Code Review
stdlib/Serialization/src/Serialization.jl:1
@@ -847,6 +863,18 @@ Open a file and deserialize its contents.
 """
 deserialize(filename::AbstractString) = open(deserialize, filename)
 
+"""
+    deserialize(data::Vector{UInt8})
+
+Deserialize the given byte vector and return the resulting value.
+
+See [`deserialize(::IO)`](@ref deserialize(::IO)) for more details and caveats.
+
+!!! compat "Julia 1.13"

!!! compat "Julia 1.14"

adienes adienes commented on code on Dec 12, 2025 20:04 UTC
Code Review
stdlib/Serialization/src/Serialization.jl:1
@@ -847,6 +863,18 @@ Open a file and deserialize its contents.
 """
 deserialize(filename::AbstractString) = open(deserialize, filename)
 
+"""
+    deserialize(data::Vector{UInt8})
+
+Deserialize the given byte vector and return the resulting value.
+
+See [`deserialize(::IO)`](@ref deserialize(::IO)) for more details and caveats.
+
+!!! compat "Julia 1.13"
+    This method is available as of Julia 1.13.

    This method is available as of Julia 1.14.

DilumAluthge DilumAluthge commented on Jan 31, 2026 01:27 UTC
Contributor

@aplavin Can you update the compat notes to 1.14, as suggested by @adienes? Also, can you rebase on the latest Julia master?

Once the above two tasks are done, and once CI is green, @JeffBezanson @LilithHafner can I merge this?

LilithHafner LilithHafner commented on Jan 31, 2026 20:29 UTC
Contributor

I think triage should talk briefly about API just to confirm. e.g. we should talk about https://github.com/JuliaLang/julia/pull/60315#issuecomment-3647930774

JeffBezanson JeffBezanson commented on Mar 12, 2026 18:11 UTC
Contributor

From triage: we think it's fine to use Vector{UInt8}, no need to overthink it. PR approved.

Reviewers
Assignees
aplavin aplavin
Labels
risk: low confidence: 83.9% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 32.7% (LOW) · Higher = larger blast radius
32.7%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 83.9% · Lower = rushed or shallow review
83.9%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 5.3% · Safe to merge
5.3%