pyld
pyld copied to clipboard
Every .expand request downloads 130K file from schema.org
I suggest to add some caching because if the library is called many times it's painfully slow
cache = {}
def caching_document_loader(url):
loader = jsonld.requests_document_loader()
if url in cache:
return cache[url]
resp = loader(url)
cache[url] = resp
return resp
jsonld.set_document_loader(caching_document_loader)