{
  "schemaVersion": 1,
  "slug": "ty-vs-mypy-typecheck",
  "tool": {
    "name": "ty",
    "repo": "astral-sh/ty",
    "version": "0.0.102"
  },
  "environment": {
    "arch": "aarch64",
    "cpu": "Neoverse-N1 x2, CPUQuota 150%",
    "memMB": 2048,
    "os": "Ubuntu 24.04.4 LTS",
    "runtime": "Python 3.12.3",
    "installSeconds": 7.5,
    "installBytes": 123872580
  },
  "method": {
    "hypothesis": "README 주장: ty가 mypy 및 Pyright보다 타입 검사 속도가 10배에서 최대 100배 빠르다고 주장한다. 이 환경에서 확인: 결정적으로 생성한 파이썬 모듈 모음을 대상으로 비증분 전체 타입 검사를 실행할 때 ty의 실행 시간이 mypy보다 짧은지 측정한다.",
    "conditions": [
      "실제 대규모 저장소와 Pyright 비교 대신 결정적으로 생성한 합성 파이썬 소스 파일 80개를 대상으로 mypy와만 비교",
      "각 파일마다 타입 어노테이션이 적용된 클래스 4개와 함수 6개를 포함해 모듈 간 참조를 구성",
      "측정 전에 워밍업을 거친 뒤 캐시 영향을 배제한 상태에서 비증분 전체 타입 검사 시간을 측정",
      "speedup이 1보다 크면 같은 방향, 1 이하이면 다른 방향, 실행 실패 시 비교 불가로 판정"
    ],
    "repeats": 5
  },
  "script": "import json\nimport os\nimport shutil\nimport subprocess\nimport sys\nimport tempfile\nimport time\n\n\ndef write_project(root: str, num_files: int = 80) -> None:\n    for i in range(num_files):\n        lines = [\"from dataclasses import dataclass\", \"\"]\n        if i > 0:\n            prev = f\"mod_{i - 1:03d}\"\n            lines.append(f\"from {prev} import Record{i - 1}A, combine_{i - 1}_0\")\n            lines.append(\"\")\n        for suffix in (\"A\", \"B\", \"C\", \"D\"):\n            cls_name = f\"Record{i}{suffix}\"\n            lines.extend([\n                \"@dataclass(frozen=True)\",\n                f\"class {cls_name}:\",\n                \"    label: str\",\n                \"    count: int\",\n                \"    score: float\",\n                \"    active: bool = True\",\n                \"\",\n                \"    def weight(self, factor: int) -> float:\",\n                \"        return self.score * float(self.count + factor)\",\n                \"\",\n            ])\n        for j in range(6):\n            fn_name = f\"combine_{i}_{j}\"\n            lines.extend([\n                f\"def {fn_name}(items: list[Record{i}A], limit: int) -> dict[str, int]:\",\n                \"    out: dict[str, int] = {}\",\n                \"    for item in items:\",\n                \"        if item.active and item.count <= limit:\",\n                \"            out[item.label] = out.get(item.label, 0) + item.count\",\n                \"    return out\",\n                \"\",\n            ])\n        if i > 0:\n            lines.extend([\n                f\"def bridge_{i}(prev_items: list[Record{i - 1}A]) -> int:\",\n                f\"    mapped = combine_{i - 1}_0(prev_items, 10)\",\n                \"    return sum(mapped.values())\",\n                \"\",\n            ])\n        with open(os.path.join(root, f\"mod_{i:03d}.py\"), \"w\", encoding=\"utf-8\") as f:\n            f.write(\"\\n\".join(lines))\n\n\ndef find_ty_cmd() -> list[str]:\n    candidate = os.path.join(os.path.dirname(sys.executable), \"ty\")\n    if os.path.isfile(candidate) and os.access(candidate, os.X_OK):\n        return [candidate, \"check\"]\n    which_ty = shutil.which(\"ty\")\n    if which_ty:\n        return [which_ty, \"check\"]\n    return [sys.executable, \"-m\", \"ty\", \"check\"]\n\n\ndef run_cmd(cmd: list[str], cwd: str) -> float:\n    start = time.perf_counter()\n    proc = subprocess.run(cmd, cwd=cwd, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=False)\n    elapsed_ms = (time.perf_counter() - start) * 1000.0\n    if proc.returncode != 0:\n        err = proc.stderr.decode(\"utf-8\", errors=\"replace\")\n        raise RuntimeError(f\"Command {cmd} failed with {proc.returncode}: {err}\")\n    return elapsed_ms\n\n\ndef main() -> None:\n    ty_cmd = find_ty_cmd()\n    with tempfile.TemporaryDirectory() as tmp:\n        warmup_dir = os.path.join(tmp, \"warmup\")\n        bench_dir = os.path.join(tmp, \"bench\")\n        warmup_cache = os.path.join(tmp, \"warmup_mypy_cache\")\n        bench_cache = os.path.join(tmp, \"bench_mypy_cache\")\n        os.makedirs(warmup_dir, exist_ok=True)\n        os.makedirs(bench_dir, exist_ok=True)\n        write_project(warmup_dir, 80)\n        write_project(bench_dir, 80)\n\n        mypy_warmup = [sys.executable, \"-m\", \"mypy\", \"--no-incremental\", \"--cache-dir\", warmup_cache, \".\"]\n        mypy_bench = [sys.executable, \"-m\", \"mypy\", \"--no-incremental\", \"--cache-dir\", bench_cache, \".\"]\n\n        run_cmd(ty_cmd, warmup_dir)\n        run_cmd(mypy_warmup, warmup_dir)\n\n        ty_ms = run_cmd(ty_cmd, bench_dir)\n        mypy_ms = run_cmd(mypy_bench, bench_dir)\n\n    print(json.dumps({\"tyMs\": round(ty_ms, 3), \"mypyMs\": round(mypy_ms, 3)}))\n\n\nif __name__ == \"__main__\":\n    main()\n",
  "scriptSha256": "8385d1ec1f8609cf0cf0bac443768ba2034e236156caa023f9af030654d0c5f2",
  "runs": [
    {
      "run": 1,
      "tyMs": 208.678,
      "mypyMs": 1614.192,
      "wallMs": 3876.296
    },
    {
      "run": 2,
      "tyMs": 208.484,
      "mypyMs": 1542.96,
      "wallMs": 3724.519
    },
    {
      "run": 3,
      "tyMs": 231.879,
      "mypyMs": 1642.414,
      "wallMs": 3884.727
    },
    {
      "run": 4,
      "tyMs": 218.014,
      "mypyMs": 1676.374,
      "wallMs": 3982.331
    },
    {
      "run": 5,
      "tyMs": 221.675,
      "mypyMs": 1665.481,
      "wallMs": 3828.991
    }
  ],
  "summary": {
    "tyMs": {
      "median": 218.014,
      "min": 208.484,
      "max": 231.879,
      "unit": "ms"
    },
    "mypyMs": {
      "median": 1642.414,
      "min": 1542.96,
      "max": 1676.374,
      "unit": "ms"
    },
    "speedup": 7.533525
  },
  "chart": {
    "title": {
      "ko": "파이썬 타입 검사 실행 시간",
      "en": "Python type checking runtime"
    },
    "series": [
      {
        "id": "ty",
        "role": "target",
        "label": {
          "ko": "ty check",
          "en": "ty check"
        },
        "short": {
          "ko": "ty",
          "en": "ty"
        }
      },
      {
        "id": "mypy",
        "role": "baseline",
        "label": {
          "ko": "mypy",
          "en": "mypy"
        },
        "short": {
          "ko": "mypy",
          "en": "mypy"
        }
      }
    ],
    "panels": [
      {
        "title": {
          "ko": "전체 타입 검사 시간",
          "en": "Full type check time"
        },
        "unit": "ms",
        "kind": "time",
        "better": "lower",
        "keys": {
          "ty": "tyMs",
          "mypy": "mypyMs"
        }
      }
    ]
  },
  "createdAt": "2026-11-13T10:04:17Z",
  "claim": {
    "quote": "10x - 100x faster than mypy and Pyright",
    "url": "https://github.com/astral-sh/ty#readme",
    "numbers": [
      100
    ]
  }
}
