ty 1.0 Migration Notes: 24x Faster at OpenAI, and How to Adopt It Safely

On December 1 Astral shipped ty 1.0 and said it is now the default type checker at OpenAI, covering millions of lines of critical Python. The migration numbers are a median 24x speedup and 73 percent lower peak memory. The story drew 616 points on the Hacker News front page that day. Numbers like these are easily read as swap it in and get 24x. Put them back into their measurement context first.

Three numbers, three scopes

The 24x is a median from OpenAI internal migration, not a cross-project benchmark. In the public benchmarks, ty is fastest on 16 of 18 ecosystem projects, 1.46 times faster than Pyrefly and 3.56 times faster than Zuban by geometric mean. In the editor benchmarks it is fastest on 14 of 17 projects, 7.73 times faster than Pyrefly. The third number is a correctness proxy: on the Python typing conformance suite, ty 1.0 records 14 false positives and 13 false negatives, versus 224 and 405 at the Beta release, and 190 and 109 for mypy.

Dropping false positives by an order of magnitude is impressive. Thirteen false negatives still mean there are cases where it says nothing. A type checker is not a proof assistant, and swapping engines does not conjure invariants into existence.

14x on this machine

Against the 23 Python files in D:/workspace/dev-tools/src, ty 1.0.0 took a median 0.080 seconds over three runs. mypy 2.4.1 with incremental checking disabled took 1.145 seconds, a ratio of about 14.3. An honest footnote: ty reported 17 diagnostics, while mypy reported 7 errors in 1 file. The rule sets differ, so the faster tool is not automatically the stricter one. Do not derive we can turn mypy off from a timing ratio.

What bidirectional inference actually catches

The new generics solver and bidirectional inference in ty 1.0 are not paper features. The code below puts a dict literal into a list[Runner] and passes it to a sorted lambda. ty carries Runner into the key function and spots the misspelled field.

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"],
    )
    return ranked[:3]
$ ty check podium.py
error[invalid-typed-dict-key]: Unknown key "second" for TypedDict `Runner`
  --> podium.py:12:35
   |
12 |         key=lambda runner: runner["second"],
   |                            ------ ^^^^^^^^ Did you mean "seconds"?
   |                            |
   |                            TypedDict `Runner`
help: Replace with "seconds"
   |
11 |         [*runners, {"name": "Ada", "seconds": 53.2}],
   -         key=lambda runner: runner["second"],
12 +         key=lambda runner: runner["seconds"],
13 |     )
   |
note: This is an unsafe fix and may change runtime behavior

Found 1 diagnostic

Astral says that of eight checkers tested, only ty both reported the bad key and accepted the function after the fix. I reproduced the first half locally. This is worth adding to your CI sample set because it tests context propagation, not just field lookup.

Migrating an old repository: baseline first, strictness later

The first run is what bites you. After setting baseline = "ty-baseline.json" in ty.toml, if that file does not exist yet, ty check reports the missing baseline itself as an invalid-baseline diagnostic and CI goes red. The correct order is to run ty check --update-baseline once, commit the generated file, and only then let CI run a plain check. New errors surface individually while old ones stay in the baseline. After fixing the new errors, update the baseline again. Absolute paths are omitted in the transcript below.

$ ty check invoice.py
error[invalid-baseline]: Failed to read baseline `ty-baseline.json`
error[invalid-explicit-return]: Return type does not match returned value
Found 2 diagnostics

$ ty check --update-baseline invoice.py
Updated baseline `ty-baseline.json` with 1 diagnostic.

$ ty check invoice.py
All checks passed!

$ ty check invoice.py
error[invalid-explicit-return]: Return type does not match returned value
 --> invoice.py:6:12
Found 1 diagnostic

$ ty check --update-baseline invoice.py
Updated baseline `ty-baseline.json` with 2 diagnostics.

The alternative is ty check --add-ignore, which inserts suppression comments for every existing diagnostic in one pass. It touches more code, but each ignored site stays visible, which suits a small backlog you want to eliminate one by one. Baselines suit get on board first, clean up later.

When to wait

Three cases would make me hold off. First, libraries relying on mypy strict to hold critical invariants: run ty in shadow mode for two weeks. Second, projects with many PEP 723 single-file scripts: the uv integration is still in preview, configured with project-manager.script = "uv". Third, generic code that needs strict narrowing: the default relaxes element types after isinstance, so enable strict-generic-narrowing explicitly. On the other hand, if you already use Ruff and uv, the marginal cost of trying ty is low.

The 24x is somebody else's median. Your own repository has an answer after three commands.

Further reading

フィードバック

このサイトはフロントエンドのみでバックエンドやアカウントはなく、フィードバックはGitHub Issues・ディスカッション・メールで受け付けています。

issueやメールに貼り付けていただくと問題特定が早まります。入力内容は含まれません

その他:既存の報告を見る · メールでのフィードバック(GitHubアカウント不要):278975598@qq.com