Skip to content

Commit

Permalink
Cache getting SourceInfo for a class
Browse files Browse the repository at this point in the history
The inspect calls invoked in this method are not very cheap, so this can be a nice speedup if called many times on the same class.

PiperOrigin-RevId: 670111306
  • Loading branch information
tomvdw authored and SeqIO committed Sep 2, 2024
1 parent 2a819e8 commit cf8c3e2
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions seqio/dataset_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class SourceInfo:
line_number: Optional[int] = None

@classmethod
@functools.lru_cache(maxsize=None)
def for_class(cls, klass) -> SourceInfo:
"""Returns info about where the given class was defined."""
try:
Expand Down

0 comments on commit cf8c3e2

Please sign in to comment.