Skip to content

Add support for binary non-XDR format#59

Open
traversc wants to merge 3 commits intovnmabus:developfrom
traversc:develop
Open

Add support for binary non-XDR format#59
traversc wants to merge 3 commits intovnmabus:developfrom
traversc:develop

Conversation

@traversc
Copy link

References to issues or other PRs

N/A

Describe the proposed changes

  • Add native binary read/write support alongside existing XDR and ASCII support.
  • Update tests to cover native-binary parsing and writing paths.
  • Minor bug fix: on big-endian systems, XDR parser would try to write to a read-only buffer to fill NAs (gets implicitly copied/writable on little endian systems)

Additional information

Round trip example

obj <- list(
  data.frame(id = c(1L, 2L), value = c("a", "b")),
  "hello"
)
con <- file("native_in.rds", "wb")
serialize(obj, con, ascii = FALSE, xdr = FALSE, version = 3)
close(con)
import rdata

py_obj = rdata.read_rds("native_in.rds")
rdata.write_rds("native_out.rds", py_obj, file_format="binary", compression=None)

with open("native_out.rds", "rb") as f:
    assert f.read(2) == b"B\n"

Checklist before requesting a review

  • I have performed a self-review of my code
  • The code conforms to the style used in this package (checked with Ruff)
    -- (pre-existing lint errors)
  • The code is fully documented and typed (type-checked with Mypy)
  • I have added thorough tests for the new/changed functionality

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 92.66055% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.44%. Comparing base (5000127) to head (23f3802).
⚠️ Report is 10 commits behind head on develop.

Files with missing lines Patch % Lines
rdata/parser/_binary.py 88.88% 4 Missing ⚠️
rdata/tests/test_write.py 80.00% 4 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop      #59      +/-   ##
===========================================
+ Coverage    94.42%   94.44%   +0.02%     
===========================================
  Files           19       21       +2     
  Lines         1992     2108     +116     
===========================================
+ Hits          1881     1991     +110     
- Misses         111      117       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@vnmabus
Copy link
Owner

vnmabus commented Feb 27, 2026

Thanks for the PR, I will check it as soon as I can.

The code conforms to the style used in this package (checked with Ruff)
-- (pre-existing lint errors)

I fixed the pre-existing errors, the ones remaining are caused by the PR.

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