In the framework, there are several places where APISite.data_repository() (and APISite.has_data_repository property) is called. Although it could be saved to a variable or a class member in some cases, for instance in pagegenerators.WikibaseItemGenerator() it may be called on every iteration. And as the site object does not cache the result, an API query is made on each call, with the same result.
Description
Description
Details
Details
Subject | Repo | Branch | Lines +/- | |
---|---|---|---|---|
Cache APISite.data_repository() using CachedRequest | pywikibot/core | master | +1 -1 |
Event Timeline
Comment Actions
I think this could work and would certaily speed things up. I'm not sure though how long the cache should be saved. Sites usually don't change data repositories (unless we consider deploying Wikibase a change) but who knows. Property datatypes were also considered stable...
Comment Actions
Change 420164 had a related patch set uploaded (by Matěj Suchánek; owner: Matěj Suchánek):
[pywikibot/core@master] Cache APISite.data_repository() using CachedRequest
Comment Actions
Change 420164 merged by jenkins-bot:
[pywikibot/core@master] Cache APISite.data_repository() using CachedRequest