﻿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
28828	Performance improvements for build_absolute_uri	gcbirzan	nobody	"In cases where a lot of URLs are generated, the performance of it is suboptimal. 

* It calls self.get_host() several times. That function does a lot of work that isn't needed more than once.
* It calls urljoin() even on the trivial case of absolute paths (which is the most common case). urljoin is quite expensive as well.

My patch fixes these by using a cached_property for the scheme://host part and by just concatenating the current scheme/host with the location when the location is absolute, doesn't change the host, and doesn't contain '.' or '..'. The last can be implemented in there, but that will just complicate the code I think, for again, a not very common case.

All the tests pass, but they did even when I wasn't checking for '.' and '..', so I added a test for that too.

While the improvements might be minor for some use cases, an example of this being slow can be found in this [https://github.com/encode/django-rest-framework/issues/3007#issuecomment-288332131 DRF ticket].

I've made a [https://github.com/django/django/pull/9376 PR] with these changes."	Uncategorized	new	Core (URLs)	dev	Normal				Unreviewed	1	0	0	0	0	0
