Skip to content

Cache unwrap and to_type_signature on type wrappers#5585

Merged
rmosolgo merged 1 commit intomasterfrom
cache-type-wrapper-results
Mar 25, 2026
Merged

Cache unwrap and to_type_signature on type wrappers#5585
rmosolgo merged 1 commit intomasterfrom
cache-type-wrapper-results

Conversation

@swalkinshaw
Copy link
Copy Markdown
Collaborator

Type wrappers (NonNull, List) are schema-level immutable objects whose unwrap and to_type_signature results never change. Memoize both to eliminate repeated recursive unwrap calls and string allocations during validation and introspection.

I can't find any reason why these wouldn't be safe to memoize.

Extracted from #5578

@rmosolgo
Copy link
Copy Markdown
Owner

It looks like some tests are failing because of the type definition being frozen. I'm open to any solution here, but my first thought is, what about adding:

def freeze 
  to_type_signature 
  super 
end 

to Wrapper?

Type wrappers (NonNull, List) are schema-level immutable objects whose
unwrap and to_type_signature results never change. Memoize both to
eliminate repeated recursive unwrap calls and string allocations during
validation and introspection.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@swalkinshaw swalkinshaw force-pushed the cache-type-wrapper-results branch from 3a5677b to e350409 Compare March 24, 2026 15:14
@swalkinshaw
Copy link
Copy Markdown
Collaborator Author

Good idea; added!

@swalkinshaw
Copy link
Copy Markdown
Collaborator Author

Last CI failure is flaky

@rmosolgo rmosolgo added this to the 2.5.23 milestone Mar 25, 2026
@rmosolgo rmosolgo merged commit 89eafc9 into master Mar 25, 2026
12 of 13 checks passed
@rmosolgo
Copy link
Copy Markdown
Owner

Thanks!

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