Skip to content

Cache unwrap and to_type_signature on type wrappers#5585

Open
swalkinshaw wants to merge 1 commit intomasterfrom
cache-type-wrapper-results
Open

Cache unwrap and to_type_signature on type wrappers#5585
swalkinshaw wants to merge 1 commit intomasterfrom
cache-type-wrapper-results

Conversation

@swalkinshaw
Copy link
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
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
Collaborator Author

Good idea; added!

@swalkinshaw
Copy link
Collaborator Author

Last CI failure is flaky

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