DEV Community

Cover image for Ty 1.0 checked FastAPI in 0.57s. mypy took 7.75s
frank chu
frank chu

Posted on

Ty 1.0 checked FastAPI in 0.57s. mypy took 7.75s

Ty 1.0 checked FastAPI in 0.57s. mypy took 7.75s

Astral shipped ty 1.0 today, and the headline number is a 24x speedup at OpenAI. I ran it myself on FastAPI — 54 files, 23,803 lines — and got 0.57 seconds cold, against 7.75 for mypy and 10.68 for pyright. The speed is real. The diagnostic counts are the interesting part.

The setup

Same machine for all three: an AMD EPYC VM, 4 vCPUs, Python 3.12. I cloned FastAPI at 0.165.0, installed it in a venv with its real dependencies (Pydantic, Starlette, the lot), and ran each checker cold — caches wiped before every run — three times each. ty 1.0.0, mypy 2.4.1 (compiled), pyright 1.1.414, all on default settings. No config files, no per-checker tuning: this is what you get out of the box.

Cold check, FastAPI 0.165.0 (54 files, 23,803 lines), median of 3 runs:

Checker    Time     Peak RSS    Diagnostics
ty 1.0.0   0.57 s    124 MB      16 (3 errors, 13 warnings)
mypy       7.75 s    327 MB       0
pyright   10.68 s    570 MB      54 errors, 1 warning

Ratios: ty is 13.6x faster than mypy, 18.7x faster than pyright.
Memory: ty uses 2.6x less than mypy, 4.6x less than pyright.
Enter fullscreen mode Exit fullscreen mode

Individual runs, so you can see the spread: ty 0.65 / 0.57 / 0.51 s; mypy 8.44 / 7.58 / 7.75 s; pyright 10.52 / 10.68 / 11.02 s. The ordering never changed. On this workload ty is not marginally faster, it is a different category — sub-second where the others are eight to eleven seconds. That is the difference between a check you run on every save and one you run in CI.

The catch: the fastest checker found the most noise

Speed is one axis. The other is what each checker says about a codebase its own maintainers keep clean. mypy reported zero issues. ty reported 16 diagnostics, pyright 54. Somebody is wrong, and it is not obvious who.

ty's 16 break down like this:

 3 error   incompatible-mutable-override: attributes `model` and `scheme`
           overridden with incompatible mutable types
 4 warning deprecated: `contextmanager` / `asynccontextmanager` overloads
 5 warning redundant-condition: always-truthy checks (tuple, string, function)
 4 warning renamed-rule-in-ignore-comment: `# ty: ignore` comments naming
           rules that were renamed before 1.0
Enter fullscreen mode Exit fullscreen mode

The three errors are the ones to stare at. FastAPI overrides model and scheme attributes in subclasses, and ty's stricter override checking flags them where mypy stays silent. Are they real bugs? FastAPI's test suite passes and mypy is happy, so at minimum they are the kind of finding you would argue about in review, not the kind you fix at midnight. pyright's 54 are dominated by reportTypedDictNotRequiredAccess complaints about optional TypedDict keys in FastAPI's telemetry module — again, a strictness choice more than a bug list.

So the honest scoreboard is: ty is dramatically faster, and on default settings it is also louder than mypy on a clean codebase. Loud is not wrong — ty's whole pitch is that it infers more from unannotated code, which means it has more opinions about code that was never annotated for it. But if you migrate a mypy-clean repo to ty tomorrow, expect a triage session, not a green check.

Reproducing the blog's two best examples

Astral's announcement leans on inference: ty figures out types from context where the others give up or guess wrong. I ran both examples verbatim.

First, the misspelled TypedDict key:

from typing import TypedDict

class Runner(TypedDict):
    name: str
    seconds: float

def podium(runners: list[Runner]) -> list[Runner]:
    ranked = sorted(
        [*runners, {"name": "Ada", "seconds": 53.2}],
        key=lambda runner: runner["second"],  # the bug
    )
    return ranked[:3]
Enter fullscreen mode Exit fullscreen mode

ty catches it and offers the fix:

error[invalid-typed-dict-key]: Unknown key "second" for TypedDict `Runner`
  --> podium.py:10:35
   |  key=lambda runner: runner["second"],
   |                            ------ ^^^^^^^^ Did you mean "seconds"?
Enter fullscreen mode Exit fullscreen mode

mypy, on the same file, reports 3 errors — and none of them is the misspelled key. It complains about the return types of sorted and the list instead. The actual bug, the one that silently sorts by nothing at runtime, sails through. That is a genuine win for ty, and it is the kind of win that matters more than the benchmark table: a checker that finds the bug you actually wrote.

Second, the conjoined-predicates example, where ty infers the input must be both Sized and Iterable[int]:

valid_batch = satisfies_all(large_enough, all_positive)
valid_batch([1, 2, 3])        # accepted
valid_batch(iter([1, 2, 3]))  # flagged
Enter fullscreen mode Exit fullscreen mode

ty accepts the list and flags the iterator, exactly as the blog claims — Expected Sized & Iterable[int], found Iterator[int]. mypy infers Never for the conjoined input and rejects both calls, also exactly as the blog claims. I verified both behaviors myself rather than trusting the screenshots.

What I did not verify

Astral's blog makes three more claims I could not reproduce on this box: the 24x median speedup and 73% peak-memory reduction from OpenAI's internal migration, the 1.46x edge over Pyrefly on their 18-project benchmark, and the conformance numbers (ty: 14 false positives / 13 false negatives, mypy: 190 / 109). Those are their measurements on their workloads, stated as theirs. My numbers point the same direction on a workload I chose — FastAPI, not their benchmark suite — but do not take my 13.6x as confirmation of their 24x. Different codebases, different stories.

One more caveat, stated plainly: this is one repo, one machine, default settings, three runs each. pyright in particular is configurable enough that a tuned setup would tell a different story on diagnostics, though not on wall time — its 10.68 seconds is mostly the checker, not the config. And cold-check time is not editor latency; ty's incremental architecture is built for the long-lived language server, which I did not measure.

Verdict

ty 1.0's speed claim survives contact with a real codebase: 0.57 seconds where mypy needs 7.75 and pyright 10.68, at a quarter of the memory. The inference examples survive too — it found a real bug mypy walked past. What does not survive untouched is the idea that you can swap checkers for free: on defaults, ty flags 16 things in a mypy-clean FastAPI, and three of them are errors you would have to adjudicate. The speed is a reason to try it. The triage list is the price of admission.

Sources

  • Astral, "ty 1.0: an extremely fast Python type checker and language server," December 1, 2026: https://astral.sh/blog/ty-1.0
  • FastAPI 0.165.0, checked December 1, 2026: https://github.com/fastapi/fastapi
  • All timings measured by me on December 1, 2026, on an AMD EPYC VM (4 vCPUs). ty 1.0.0, mypy 2.4.1, pyright 1.1.414, Python 3.12.3.

Top comments (0)