So I had a list of pages in the English Wiktionary and wanted to list only the ones that belonged to a certain category. My script preloaded the pages themselves with APISite.preloadpages and then iterated over their categories with BasePage.categories. But this is very inefficient and takes a long time, because BasePage.categories has to send a separate request to get the list of categories for a page each time it is called. Ideally these would be preloaded along with the rest of the page properties so that the script sends only one request per group of pages.
I searched through the Pywikibot docs and didn't find any way to do this. I also asked @valhallasw on IRC and he confirmed that there's no way to do this currently.
A good solution would be to add a parameter to APISite.preloadpages that would tell it to preload the categories using API:Categories and make them accessible to BasePage.categories on the pages yielded by the iterator. I'm not familiar enough with the internals of Pywikibot to fully work this out though.
@valhallasw on IRC kindly showed me some modifications to site.py that make APISite.preloadpages preload the categories and place the decoded JSON under page._preloaded["categories"] in the page objects, but that's not a long-term solution.