TensorFlow vs PyTorch: source lines of code compared

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-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.

Metrictensorflow/tensorflowpytorch/pytorch
Files24,1148,683
Total lines6,771,3263,218,930
Code lines5,078,3992,518,292
Comment lines949,226333,792
Blank lines743,701366,846
Languages counted1212

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 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.

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.