Skip to content

Commit

Permalink
fix: Add caching to speed up BoxScore loading
Browse files Browse the repository at this point in the history
the `.box_score()` method can take ~1.5s on average to load, making it very slow if your code iterates over this many times. Adding this cache makes it easier to work with and orders of magnitude faster.
  • Loading branch information
DesiPilla committed Sep 3, 2024
1 parent 1bcfdbf commit dd5fbeb
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions espn_api/football/league.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import functools
import json
import random
from typing import Callable, Dict, List, Tuple, Union
Expand Down Expand Up @@ -277,6 +278,7 @@ def scoreboard(self, week: int = None) -> List[Matchup]:

return matchups

@functools.cache
def box_scores(self, week: int = None) -> List[BoxScore]:
'''Returns list of box score for a given week\n
Should only be used with most recent season'''
Expand Down

0 comments on commit dd5fbeb

Please sign in to comment.