pyld icon indicating copy to clipboard operation
pyld copied to clipboard

Every .expand request downloads 130K file from schema.org

Open origliante opened this issue 7 years ago • 1 comments

I suggest to add some caching because if the library is called many times it's painfully slow

origliante avatar Dec 02 '17 23:12 origliante

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)

origliante avatar Dec 02 '17 23:12 origliante