Skip to content

perf(serializer): skip cycle memoization for atomic types - #8417

Closed
M-Colley wants to merge 1 commit into
getsentry:masterfrom
M-Colley:fix/issue-8091-serializer-atomic-memo
Closed

M-Colley wants to merge 1 commit into
getsentry:masterfrom
M-Colley:fix/issue-8091-serializer-atomic-memo

Conversation

@M-Colley

Copy link
Copy Markdown

Description

_Serializer._serialize_node() previously wrapped every node in self.memo.memoize(obj) for cycle detection, including exact built-in str, int, float, bool, and None values. Exact built-in atomic values cannot hold object references or form cycles, so this change adds an _ATOMIC_TYPES fast path in _Serializer._serialize_node() that invokes _serialize_node_impl() directly for those types. Consequently, container types and str, int, or float subclasses retain full cycle memoization, path tracking, metadata cleanup, and error handling. Furthermore, test_atomic_values_skip_memo in tests/test_serializer.py verifies that exact atomic values bypass Memo.memoize with identical serialized output.

Issues

Fixes getsentry#8091

Signed-off-by: Mark Colley <39366189+M-Colley@users.noreply.github.com>
@M-Colley
M-Colley requested a review from a team as a code owner November 28, 2026 10:47
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR risk: medium

For commit 32d8b47.

Main concerns: reach.

This label is a hint for reviewers, not an approval.

@sentrivana sentrivana closed this Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf: serialize() memoizes atomic values (str/int/None) for cycle detection

2 participants