[PY-82607] introduce a caching for all computations in PyTypingTypeProvider

GitOrigin-RevId: ad795a4fc2bed8dc7f5276eb18c80a51485dcabf
This commit is contained in:
Vladimir.Koshelev
2025-08-01 17:44:21 +00:00
committed by intellij-monorepo-bot
parent 98942f9977
commit 447a7d0891
4 changed files with 39 additions and 3 deletions
@@ -52,7 +52,8 @@ public sealed class TypeEvalContext {
protected final Map<PyTypedElement, PyType> myEvaluated = createMap();
protected final Map<PyCallable, PyType> myEvaluatedReturn = createMap();
@ApiStatus.Internal
protected final Map<Pair<PyExpression, Object>, PyType> contextTypeCache = createMap();
/**
* AssumptionContext invariant requires that if type is in the map,
* it's dependencies are also in the map, so we can't use softValueMap.
@@ -330,6 +331,11 @@ public sealed class TypeEvalContext {
return myConstraints.myOrigin;
}
@ApiStatus.Internal
public @NotNull Map<Pair<PyExpression, Object>, PyType> getContextTypeCache() {
return contextTypeCache;
}
/**
* @return context constraints (see {@link TypeEvalConstraints}
*/