refactor serialize_json to use custom JSONEncoder for ~3.7x speedup#450
Merged
essweine merged 1 commit intofeature/performancefrom Apr 17, 2026
Merged
refactor serialize_json to use custom JSONEncoder for ~3.7x speedup#450essweine merged 1 commit intofeature/performancefrom
essweine merged 1 commit intofeature/performancefrom
Conversation
Instead of two passes (Python dict-building + json.dumps), serialize_json now uses a SpiffEncoder that lets the C-level JSON encoder handle plain data traversal natively, only calling back to Python for registered types. Periodic serialization test (300 items, 180 serializations): | Metric | Before | After | Improvement | |--------------------------------|----------|---------|---------------| | Total time | 162.5s | 45.0s | 3.6x faster | | Total serialization | 160.7s | 43.3s | 3.7x faster | | Avg per serialization | 0.893s | 0.241s | 3.7x faster | | Final checkpoint (308 tasks) | 2.07s | 0.56s | 3.7x faster | Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
|
I guess this is not terrible, though all these changes are not really addressing the problem, which is that if you need to work with large amounts of data attached to each task, the library isn't the appropriate place to deal with it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Instead of two passes (Python dict-building + json.dumps), serialize_json now uses a SpiffEncoder that lets the C-level JSON encoder handle plain data traversal natively, only calling back to Python for registered types.
Periodic serialization test (300 items, 180 serializations):