Skip to content

Use the stdlib json module instead of simplejson; bump to 1.3.0 - #22

Merged
iskandr merged 1 commit into
masterfrom
stdlib-json
Oct 6, 2026
Merged

iskandr merged 1 commit into
masterfrom
stdlib-json

Conversation

@iskandr

@iskandr iskandr commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #21. vaxrank used to import simplejson without declaring it, getting it through this package. openvax/vaxrank#580 switched it to the stdlib, and that's released in vaxrank 3.38.2, so nothing in openvax still imports simplejson.

Supersedes #10. Part of #15; the unused typechecks and coveralls dependencies are left for a separate change, since pyensembl and varcode import typechecks themselves.

Changes

  • Replace simplejson with the stdlib json module. Output is byte-identical:
    • against golden payloads from 1.1.1;
    • on edge cases: numpy float64, IntEnum, float Enum, str subclasses, -0.0, denormals, huge ints, non-ASCII strings and lone surrogates.
  • Faster encoding and decoding. Stdlib json.dumps takes 6.5 ms vs 10.5 ms for simplejson on a 1.6 MB payload; loads takes 7.1 ms vs 8.3 ms.
  • NaN handling is now explicit. It used to depend on the installed simplejson: 3.19+ rejects NaN, older versions write and read it.
    • to_json raises ValueError for NaN/inf (allow_nan=False). That's what users with current simplejson get today, so existing output and vaxrank's content hashes don't change.
    • from_json accepts NaN/Infinity, so files written with simplejson < 3.19 load again.
    • Both are tested and documented in the README.
  • Documented. The NaN behavior is described in the README's Limitations and in the "Format and limitations" section of docs/index.md.
  • Drops the simplejson dependency.

https://claude.ai/code/session_01JRDMg3F5kNKmnjv5jvQBgr

@coveralls

coveralls commented Oct 6, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 37524397957

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Coverage remained the same at 91.322%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • 10 coverage regressions across 1 file.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

10 previously-covered lines in 1 file lost coverage.

File Lines Losing Coverage Coverage
helpers.py 10 91.89%

Coverage Stats

Coverage Status
Relevant Lines: 242
Covered Lines: 221
Line Coverage: 91.32%
Coverage Strength: 0.91 hits per line

💛 - Coveralls

@iskandr
iskandr force-pushed the types-and-ci branch 2 times, most recently from 36e2dc4 to a970445 Compare October 6, 2026 19:48
@iskandr
iskandr changed the base branch from types-and-ci to master October 6, 2026 20:09
simplejson was a Python 2 era backport of json (see #10). The stdlib
encoder is faster and produces byte-identical output for everything
serializable emits (checked against golden payloads, including numpy
float64 / IntEnum / float-Enum values, -0.0, denormals, huge ints and
non-ASCII strings).

NaN handling is now explicit instead of depending on the installed
simplejson version (>=3.19 rejects NaN by default, older versions
accept it):
- to_json raises ValueError for NaN/inf (allow_nan=False), matching
  simplejson>=3.19, so existing output and content hashes don't change.
- from_json accepts NaN/Infinity, so files written with older simplejson
  versions can be read again.

Drops the simplejson dependency. vaxrank imports simplejson without
declaring it, so openvax/vaxrank#580 should be released first.

Supersedes PR #10. Part of #15 (the typechecks and coveralls dependencies are
left for a separate change).

Claude-Session: https://claude.ai/code/session_01JRDMg3F5kNKmnjv5jvQBgr
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.

2 participants