Skip to content

Commit

Permalink
Adds small optimization of subclasses
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Matyasek committed May 13, 2019
1 parent 8fe1532 commit 44f33e6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ftoolz/unsafe/reflection.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ def subclasses(clz: Type[T], package: str) -> Set[Type[T]]:
"""

def rec(cls: Type[T]) -> Set[Type[T]]:
return set(cls.__subclasses__()) \
.union([s for c in cls.__subclasses__() for s in rec(c)])
sub = set(cls.__subclasses__())
return sub.union(s for c in sub for s in rec(c))

import_all(package)
return rec(clz)

0 comments on commit 44f33e6

Please sign in to comment.