﻿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
35246	Make Field.unique a plain attribute	Adam Johnson	Adam Johnson	"Another candidate for caching, like #35230, #35232 and #35241, following the same system check profiling.

`Field.unique` is a simple property that computes whether a field is unique from two inputs:

{{{
@property
def unique(self):
    return self._unique or self.primary_key
}}}

The result is immutable because the two input attributes shouldn’t change.

I found this method was called 3543 times during system checks, taking ~0.7% (~0.3ms) of the total runtime on a Python 3.12 project with 118 models. After moving it to a plain attribute, this cost is eliminated. (cProfile’s overhead biases the cost of function calls upwards, so the actual saving may be smaller, but it still seems worth the minimal change.)

`unique` is accessed in many other code paths so this change will help those paths too."	Cleanup/optimization	assigned	Database layer (models, ORM)	dev	Normal				Unreviewed	1	0	0	0	0	0
