Skip to content

Commit 0dec214

Browse files
committed
Cache response
1 parent bf47e6d commit 0dec214

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

_tools/generate_release_cycle.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import csv
88
import datetime as dt
99
import json
10+
from functools import cache
1011
from pathlib import Path
1112
from urllib.request import urlopen
1213

@@ -39,12 +40,17 @@ def parse_version(ver: str) -> list[int]:
3940
return [int(i) for i in ver["key"].split(".")]
4041

4142

43+
@cache
44+
def get_versions() -> str:
45+
with urlopen("https://peps.python.org/api/release-cycle.json") as in_file:
46+
return json.loads(in_file.read().decode("utf-8"))
47+
48+
4249
class Versions:
4350
"""For converting JSON to CSV and SVG."""
4451

4552
def __init__(self, *, limit_to_active=False, special_py27=False) -> None:
46-
with urlopen("https://peps.python.org/api/release-cycle.json") as in_file:
47-
self.versions = json.loads(in_file.read().decode("utf-8"))
53+
self.versions = get_versions()
4854

4955
# Generate a few additional fields
5056
for key, version in self.versions.items():

0 commit comments

Comments
 (0)