Skip to content

Commit 1ebcb23

Browse files
ktosiekCito
authored andcommitted
Use identity instead of hash for caching subfields in collect_subfields (#56)
This is closer to what GraphQL.js does, and performs much better.
1 parent b1bfc47 commit 1ebcb23

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/graphql/execution/execute.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def __init__(
210210
self.errors = errors
211211
self.middleware_manager = middleware_manager
212212
self._subfields_cache: Dict[
213-
Tuple[GraphQLObjectType, Tuple[FieldNode, ...]], Dict[str, List[FieldNode]]
213+
Tuple[GraphQLObjectType, int], Dict[str, List[FieldNode]]
214214
] = {}
215215

216216
@classmethod
@@ -987,7 +987,7 @@ def collect_subfields(
987987
subfields are not repeatedly calculated, which saves overhead when resolving
988988
lists of values.
989989
"""
990-
cache_key = return_type, tuple(field_nodes)
990+
cache_key = return_type, id(field_nodes)
991991
sub_field_nodes = self._subfields_cache.get(cache_key)
992992
if sub_field_nodes is None:
993993
sub_field_nodes = {}

0 commit comments

Comments
 (0)