Page MenuHomePhabricator

Iterating Wikidata can be inefficient because APISite.data_repository() isn't cached
Closed, ResolvedPublic

Description

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.

Event Timeline

Or the request could be a CachedRequest?

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...

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

https://gerrit.wikimedia.org/r/420164

Xqt triaged this task as High priority.Mar 17 2018, 12:46 PM

Change 420164 merged by jenkins-bot:
[pywikibot/core@master] Cache APISite.data_repository() using CachedRequest

https://gerrit.wikimedia.org/r/420164