jenkins-bot merged this change.

View Change

Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified Cache the result of _get_cache_dir

_get_cache_dir gets called on every CachedRequest.submit() and it involved
a disk access in _make_dir function. Disk access is slow and does not seem
necessary for every submit.

- Cache the result of _get_cache_dir by letting it overwrite itself on
first call.

The downside is that users no longer will be able to change the cache
directory dynamically by changing pywikibot.config2.base_dir value, but
I don't see why anyone would want to do that. Therefore, hopefully, this
minor change will not break any code.

Change-Id: Ib5275be8bd8cca7b8f211b137646da613f371328
M pywikibot/data/
1 file changed, 1 insertion(+), 0 deletions(-)

diff --git a/pywikibot/data/ b/pywikibot/data/
index de17ab5..8d7d3c1 100644
--- a/pywikibot/data/
+++ b/pywikibot/data/
@@ -2262,6 +2262,7 @@
path = os.path.join(pywikibot.config2.base_dir,
+ cls._get_cache_dir = classmethod(lambda c: path) # cache the result
return path


To view, visit change 441011. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib5275be8bd8cca7b8f211b137646da613f371328
Gerrit-Change-Number: 441011
Gerrit-PatchSet: 1
Gerrit-Owner: Dalba <>
Gerrit-Reviewer: John Vandenberg <>
Gerrit-Reviewer: Xqt <>
Gerrit-Reviewer: Zoranzoki21 <>
Gerrit-Reviewer: jenkins-bot