[ty] Avoid recursion guards for non-generic nominal targets (#29202)
Comparisons between nominal instances with a non-generic target only
inspect MRO class identities. Skip the recursion guard for these
comparisons, avoiding its bookkeeping. Tuple targets and specialized
generic targets retain the guard because their element or type-argument
comparisons can recurse.
Related to astral-sh/ty#4676.
## Test plan
Parent: `4830211afdd4`. Head: `10168bb1e5dc`.
Measured on Apple Silicon with macOS 26.7.1 using optimized debug builds
(opt-level 1, LTO off). Criterion values are medians of three run means;
CLI values are medians of 15 warmed runs, with variants interleaved.
Reductions use geometric means of matched head/parent ratios (which
differ from ratios of the displayed medians); small Criterion
differences remain uncertain with only three rounds.
| Workload | Parent median | Head median | Paired time reduction |
| --- | --- | --- | --- |
| 8 cases, Criterion | 0.195 s | 0.175 s | +9.1% |
| 16 cases, Criterion | 1.874 s | 1.687 s | +11.6% |
| 8 cases, CLI | 0.193 s | 0.177 s | +6.6% |
| 32 cases, CLI | 12.139 s | 10.666 s | +11.8% |
The eight-case CLI comparison is inconclusive in this run; the
sixteen-case Criterion benchmark and 32-case CLI example show clearer
gains.
The 32-case CLI input uses the original issue’s tuple/class-pattern
workload scaled to 32 cases; it is a separate fixture from the 16-case
Criterion workload.
CodSpeed results on the PR look like a smaller improvement than measured
locally, but still significant.
The [automatic CodSpeed
report](https://github.com/astral-sh/ruff/pull/29202#issuecomment-6045690229)
compares `10168bb` with `4830211`. It identifies a 4.05% efficiency
improvement in the eight-case CPU simulation benchmark, with 179 metrics
classified as untouched and 60 skipped.