Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6fcc3b7

Browse files
committed
Use functools.cache in redirects script.
1 parent a575269 commit 6fcc3b7

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

_websiteutils/make_redirects_links.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python3
22

33
import argparse
4+
import functools
45
import logging
56
import multiprocessing
67
import os
@@ -53,22 +54,17 @@
5354
logging.basicConfig(level=logging.DEBUG)
5455

5556

56-
# beware of triksy mutable defaults!
57-
def findlast(fname, tocheck, *, _cache={}):
57+
@functools.cache
58+
def findlast(fname, tocheck):
5859
"""
5960
Check the directories listed in ``tocheck`` to see if they have
6061
``fname`` in them. Return the first one found, or None
6162
"""
62-
if fname in _cache:
63-
return _cache[fname]
6463
for t in tocheck:
6564
pnew = t / fname
6665
if pnew.exists():
67-
_cache[fname] = t
6866
return t
69-
else:
70-
_cache[fname] = None
71-
return None
67+
return None
7268

7369

7470
html_redirect = """<!DOCTYPE HTML>

0 commit comments

Comments
 (0)