The TensorFlow vs PyTorch comparison on OctoCounts shows side-by-side source line counts for tensorflow/tensorflow and pytorch/pytorch, counted under the rules and on the dates stated below: files, total lines, code lines, comment lines, blank lines, and per-language totals, pinned to the exact commits listed below.
This page compares the source lines of code (SLOC) of tensorflow/tensorflow and pytorch/pytorch using cached OctoCounts reports. Code size is not code quality: a larger count only means more source material, not a better or worse project.
As of 2026-11-05, tensorflow/tensorflow contains 6,966,036 total lines (5,244,806 code) across 24,417 files, while pytorch/pytorch contains 3,393,187 total lines (2,658,260 code) across 9,054 files as of 2026-11-05. tensorflow/tensorflow has about 2.0x the counted code lines of pytorch/pytorch under the same engine and counting rules. Code size is not code quality: a larger count only means more source material, not a better or worse project.
| Metric | tensorflow/tensorflow | pytorch/pytorch |
|---|---|---|
| Files | 24,417 | 9,054 |
| Total lines | 6,966,036 | 3,393,187 |
| Code lines | 5,244,806 | 2,658,260 |
| Comment lines | 961,487 | 352,769 |
| Blank lines | 759,743 | 382,158 |
| Languages counted | 40 | 34 |
Top languages in tensorflow/tensorflow: C++ (56.7% of code), Python (18.3% of code), C Header (10.2% of code). Top languages in pytorch/pytorch: Python (47.7% of code), C++ (25.5% of code), C Header (16.8% of code). C++, Python, C Header appear in both top language lists; Bazel, HTML appear only in tensorflow/tensorflow's top languages; CUDA, C appear only in pytorch/pytorch's top languages.
Methodology: both counts come from cached OctoCounts reports generated with tokei. tensorflow/tensorflow was counted at ref master (commit 8eac1b6d2482) on 2026-11-05; pytorch/pytorch was counted at ref main (commit aa6d3e93992a) on 2026-11-05. See the counting methodology for ignored directories and analysis options.
Both reports use the same engine and effective counting rules. Repository declarations, when enabled, are specific to each repository. tensorflow/tensorflow: tokei-15.0.0, policy directories-v1; docs excluded, tests excluded, generated excluded. Excluded directory names: .cache, .generated, .git, .next, __tests__, build, dist, doc, docs, documentation, fixtures, gen, generated, node_modules, target, test, tests, vendor. Ignored languages: none. Repository declarations: off. Exclusions are rule-based; they do not prove that every test, document or generated file was removed. pytorch/pytorch: tokei-15.0.0, policy directories-v1; docs excluded, tests excluded, generated excluded. Excluded directory names: .cache, .generated, .git, .next, __tests__, build, dist, doc, docs, documentation, fixtures, gen, generated, node_modules, target, test, tests, vendor. Ignored languages: none. Repository declarations: off. Exclusions are rule-based; they do not prove that every test, document or generated file was removed.
Background observations recorded on 2026-09-16; language descriptions here are historical context, not claims about the current filtered shares. Use this page's measured language breakdown for current counts. Repository layout before counting filters: tensorflow/tensorflow is the TensorFlow monorepo: the C++ runtime and kernels, the Python frontend, XLA, and a large test and example corpus. pytorch/pytorch is the PyTorch core repository: the Python frontend, the ATen/TH C++ and CUDA kernels, and its own tests and tooling. Both are full machine-learning framework source trees, counted on the dates shown in the methodology line above.
Both projects include native compute components and Python-facing APIs. Language totals alone do not distinguish kernels from frontend code or indicate the amount of functionality available to a model author.
The per-language tables show a different center of gravity for each project — TensorFlow's counted code is dominated by C++ (kernels and runtime) while PyTorch's tree leans further toward its Python frontend — which is visible directly in the language breakdown rather than needing to be inferred from the totals.
Repository size does not measure training speed, memory use, or model quality for a given workload — those depend on the kernels exercised and the hardware, not on how many source lines the framework tree contains.
Sources: tensorflow/tensorflow repository · pytorch/pytorch repository. Statements verified 2026-09-16.
Evidence and next steps:
Saved reports remain subject to cache cleanup and replacement. Export their JSON for durable citation; live report URLs can change.
Note: code size is not code quality. OctoCounts only reports reproducible line counts and makes no claim that either project is better.
As of 2026-11-05, tensorflow/tensorflow contains 6,966,036 total lines (5,244,806 code) across 24,417 files, while pytorch/pytorch contains 3,393,187 total lines (2,658,260 code) across 9,054 files as of 2026-11-05. tensorflow/tensorflow has about 2.0x the counted code lines of pytorch/pytorch under the same engine and counting rules. Code size is not code quality: a larger count only means more source material, not a better or worse project.
Not necessarily. SLOC measures size, not complexity, quality, or maintainability. A larger codebase can mean more features, more generated or vendored code, more verbose language idioms, or more tests — none of which imply the code is harder to work with. Use SLOC to gauge the scale of what you'd be reading or maintaining, not as a quality signal for tensorflow/tensorflow, pytorch/pytorch, or any repository.
Methodology: both counts come from cached OctoCounts reports generated with tokei. tensorflow/tensorflow was counted at ref master (commit 8eac1b6d2482) on 2026-11-05; pytorch/pytorch was counted at ref main (commit aa6d3e93992a) on 2026-11-05. See the counting methodology for ignored directories and analysis options.
Yes. This page shows the default branch for each repository. Use the interactive comparison tool to pick any public GitHub repository, branch, tag, or commit SHA for both sides and get a fresh side-by-side report.