TensorFlow vs PyTorch: source lines of code compared
As of 2026-07-27, tensorflow/tensorflow contains 6,604,906 total lines (4,947,470 code) across 23,752 files, while pytorch/pytorch contains 3,133,439 total lines (2,450,358 code) across 8,538 files as of 2026-07-27. 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 | pytorch/pytorch |
|---|
| Files | 23,752 | 8,538 |
| Total lines | 6,604,906 | 3,133,439 |
| Code lines | 4,947,470 | 2,450,358 |
| Comment lines | 930,550 | 324,140 |
| Blank lines | 726,886 | 358,941 |
| Languages counted | 12 | 12 |
Top languages in tensorflow/tensorflow: C++ (55.4% of code), Python (18.6% of code), C Header (10.6% of code). Top languages in pytorch/pytorch: Python (45.7% of code), C++ (26.7% of code), C Header (17.6% 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 c8cae04f033e) on 2026-07-27; pytorch/pytorch was counted at ref main (commit 88b461cb1ae8) on 2026-07-27. See the counting methodology for ignored directories and analysis options.
Evidence and next steps:
Note: code size is not code quality. OctoCounts only reports reproducible line counts and makes no claim that either project is better.