mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-04-07 03:00:26 -04:00
pass tuple for strs to startswith (#2986)
This commit is contained in:
@@ -93,5 +93,5 @@ def least_upper_dtype(*ds:DType) -> DType:
|
||||
def least_upper_float(dt:DType) -> DType: return dt if dtypes.is_float(dt) else least_upper_dtype(dt, dtypes.float32)
|
||||
|
||||
# HACK: staticmethods are not callable in 3.8 so we have to compare the class
|
||||
DTYPES_DICT = {k: v for k, v in dtypes.__dict__.items() if not (k.startswith('__') or k.startswith('default') or v.__class__ is staticmethod)}
|
||||
DTYPES_DICT = {k: v for k, v in dtypes.__dict__.items() if not (k.startswith(('__', 'default')) or v.__class__ is staticmethod)}
|
||||
INVERSE_DTYPES_DICT = {v:k for k,v in DTYPES_DICT.items()}
|
||||
|
||||
@@ -147,7 +147,7 @@ def diskcache_put(table:str, key:Union[Dict, str, int], val:Any):
|
||||
# *** http support ***
|
||||
|
||||
def fetch(url:str, name:Optional[Union[pathlib.Path, str]]=None, allow_caching=not getenv("DISABLE_HTTP_CACHE")) -> pathlib.Path:
|
||||
if url.startswith("/") or url.startswith("."): return pathlib.Path(url)
|
||||
if url.startswith(("/", ".")): return pathlib.Path(url)
|
||||
fp = pathlib.Path(name) if name is not None and (isinstance(name, pathlib.Path) or '/' in name) else pathlib.Path(_cache_dir) / "tinygrad" / "downloads" / (name if name else hashlib.md5(url.encode('utf-8')).hexdigest()) # noqa: E501
|
||||
if not fp.is_file() or not allow_caching:
|
||||
with request.urlopen(url, timeout=10) as r:
|
||||
|
||||
Reference in New Issue
Block a user