﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
32850	Sitemap.items() gets called several times: Fix or document?	Thomas Güttler	Thomas Güttler	"The [https://docs.djangoproject.com/en/3.2/ref/contrib/sitemaps/#django.contrib.sitemaps.Sitemap.items Sitemap.items()] method might get called several times (if you generate several pages in batch)

This is confusing and might waste computation resources.

{{{
    def _urls(self, page, protocol, domain):
        urls = []
        latest_lastmod = None
        all_items_lastmod = True  # track if all items have a lastmod
        paginator_page = self.paginator.page(page)
        for item in paginator_page.object_list:
            loc = f'{protocol}://{domain}{self._location(item)}'
            ....
}}}

{{{
    @property
    def paginator(self):
        return paginator.Paginator(self._items(), self.limit)

}}}

I see two options now:

Option1: Document this behaviour.

Option2: make paginator a cached_property.

"	Cleanup/optimization	closed	Documentation	3.2	Normal	fixed			Ready for checkin	1	0	0	0	0	0
