# TensorFlow vs PyTorch: source lines of code compared

As of 2026-09-07, tensorflow/tensorflow contains 6,771,326 total lines (5,078,399 code) across 24,114 files, while pytorch/pytorch contains 3,218,930 total lines (2,518,292 code) across 8,683 files as of 2026-09-10. tensorflow/tensorflow is about 2.0x the size of pytorch/pytorch by code lines. Code size is not code quality: a larger count only means more source material, not a better or worse project.

| Metric | [tensorflow/tensorflow](https://octocounts.com/github/tensorflow/tensorflow) | [pytorch/pytorch](https://octocounts.com/github/pytorch/pytorch) |
| --- | ---: | ---: |
| Files | 24,114 | 8,683 |
| Total lines | 6,771,326 | 3,218,930 |
| Code lines | 5,078,399 | 2,518,292 |
| Comment lines | 949,226 | 333,792 |
| Blank lines | 743,701 | 366,846 |
| Languages counted | 12 | 12 |

Top languages in tensorflow/tensorflow: C++ (56.0% of code), Python (18.3% of code), C Header (10.5% of code). Top languages in pytorch/pytorch: Python (46.3% of code), C++ (26.2% of code), C Header (17.3% 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 01990a8ef1f8) on 2026-09-07; pytorch/pytorch was counted at ref main (commit cd96aa6ae455) on 2026-09-10. See the [counting methodology](https://octocounts.com/docs/methodology) for ignored directories and analysis options.
Evidence and next steps:

- [tensorflow/tensorflow SLOC report](https://octocounts.com/github/tensorflow/tensorflow)
- [pytorch/pytorch SLOC report](https://octocounts.com/github/pytorch/pytorch)
- [Compare tensorflow/tensorflow and pytorch/pytorch interactively](https://octocounts.com/compare?left=https%3A%2F%2Fgithub.com%2Ftensorflow%2Ftensorflow&right=https%3A%2F%2Fgithub.com%2Fpytorch%2Fpytorch)

Note: code size is not code quality. OctoCounts only reports reproducible line counts and makes no claim that either project is better.

## Compare FAQ

### Which has more lines of code, tensorflow/tensorflow or pytorch/pytorch?

tensorflow/tensorflow has more code: 5,078,399 code lines versus 2,518,292 for pytorch/pytorch, about 2.0x as much, based on cached OctoCounts reports as of 2026-09-10.

### Does more source lines of code mean more complexity?

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.

### How is this comparison calculated?

Methodology: both counts come from cached OctoCounts reports generated with tokei. tensorflow/tensorflow was counted at ref master (commit 01990a8ef1f8) on 2026-09-07; pytorch/pytorch was counted at ref main (commit cd96aa6ae455) on 2026-09-10. See the counting methodology for ignored directories and analysis options.

### Can I compare a different branch, tag, or commit?

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.

## Related OctoCounts pages

- [Interactive repository comparison](https://octocounts.com/compare)
- [Recently analyzed repositories](https://octocounts.com/recent)
- [Popular SLOC reports](https://octocounts.com/popular)
- [Trending GitHub repositories](https://octocounts.com/trending)
- [Hall of Monoliths](https://octocounts.com/hall-of-monoliths)
- [GitHub SLOC counter guide](https://octocounts.com/docs/github-sloc-counter)
- [Counting methodology](https://octocounts.com/docs/methodology)
- [OctoCounts API docs](https://octocounts.com/docs/api)
