Skip to content

Commit

Permalink
perf: Avoid dictionary creation when accessing members of non-classes…
Browse files Browse the repository at this point in the history
… with subscript syntax
  • Loading branch information
pawamoy committed Dec 26, 2024
1 parent 8dd5749 commit 0279998
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/_griffe/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,9 @@ def all_members(self) -> dict[str, Object | Alias]:
This method is part of the consumer API:
do not use when producing Griffe trees!
"""
return {**self.inherited_members, **self.members} # type: ignore[attr-defined]
if self.is_class: # type: ignore[attr-defined]
return {**self.inherited_members, **self.members} # type: ignore[attr-defined]
return self.members # type: ignore[attr-defined]

@property
def modules(self) -> dict[str, Module]:
Expand Down

0 comments on commit 0279998

Please sign in to comment.