Skip to content

Commit f8d9f2f

Browse files
heikkitoivonencodex
andcommitted
Add: Complexity row count script
Co-Authored-By: Codex <codex@openai.com>
1 parent 4e3209c commit f8d9f2f

2 files changed

Lines changed: 70 additions & 2 deletions

File tree

docs/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ See [Built-in Types](builtins/list.md) for detailed analysis.
4444

4545
- **Python Versions**: 3.9-3.14
4646
- **Implementations**: CPython, PyPy, Jython, IronPython
47-
- **Operations**: Over 100+ built-in and stdlib operations
47+
- **Operations**: 2,200+ built-in and stdlib operations
4848
- **Updates**: Regularly updated with new Python releases
4949

5050
## Why Trust This Documentation?
5151

52-
This documentation has been reviewed and refined through **100+ commits** by multiple AI coding agents (Amp, Claude, Gemini CLI, Kiro, Copilot, Codex) and models (Opus 4.5, Sonnet 4.5, Gemini 3 Pro, gpt-5.2-codex, ...) working alongside human contributors. Each agent brings different perspectives and catches different issues, resulting in thorough cross-validation. A growing unit test suite validates complexity claims against actual Python behavior.
52+
This documentation has been reviewed and refined by multiple AI coding agents (Amp, Claude, Gemini CLI, Kiro, Copilot, Codex) and models (Opus 4.5, Sonnet 4.5, Gemini 3 Pro, gpt-5.2-codex, ...) working alongside human contributors. Each agent brings different perspectives and catches different issues, resulting in thorough cross-validation. A growing unit test suite validates complexity claims against actual Python behavior.
5353

5454
It's also **fully open source**—anyone can review the content, [file issues](https://github.com/heikkitoivonen/python-time-space-complexity/issues), or [submit improvements](https://github.com/heikkitoivonen/python-time-space-complexity/pulls). All sources are cited, and claims are based on official Python documentation and CPython source code.
5555

scripts/count_complexity_rows.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/usr/bin/env python3
2+
from __future__ import annotations
3+
4+
import argparse
5+
from pathlib import Path
6+
7+
8+
def is_separator(line: str) -> bool:
9+
stripped = line.strip()
10+
if not stripped:
11+
return False
12+
if not set(stripped) <= set("|-: "):
13+
return False
14+
return "-" in stripped
15+
16+
17+
def count_tables(path: Path) -> int:
18+
lines = path.read_text(encoding="utf-8").splitlines()
19+
total = 0
20+
i = 0
21+
while i < len(lines):
22+
line = lines[i].strip()
23+
if line.startswith("|") and "Time" in line and "Space" in line and "Notes" in line:
24+
if i + 1 < len(lines) and is_separator(lines[i + 1]):
25+
i += 2
26+
while i < len(lines):
27+
row = lines[i].strip()
28+
if not row.startswith("|") or row == "|":
29+
break
30+
if not is_separator(row):
31+
total += 1
32+
i += 1
33+
continue
34+
i += 1
35+
return total
36+
37+
38+
def main() -> int:
39+
parser = argparse.ArgumentParser(
40+
description="Count complexity table rows (Time/Space/Notes) in docs."
41+
)
42+
parser.add_argument(
43+
"--root",
44+
default="docs",
45+
help="Root docs directory to scan (default: docs).",
46+
)
47+
args = parser.parse_args()
48+
49+
root = Path(args.root)
50+
counts = {path: count_tables(path) for path in root.rglob("*.md")}
51+
52+
total_rows = sum(counts.values())
53+
files_with_rows = sum(1 for v in counts.values() if v)
54+
55+
def sum_for(subdir: str) -> int:
56+
return sum(v for p, v in counts.items() if p.parts[:2] == (root.name, subdir))
57+
58+
print(f"total_rows {total_rows}")
59+
print(f"total_files_with_rows {files_with_rows}")
60+
print(f"builtins_rows {sum_for('builtins')}")
61+
print(f"stdlib_rows {sum_for('stdlib')}")
62+
print(f"versions_rows {sum_for('versions')}")
63+
print(f"implementations_rows {sum_for('implementations')}")
64+
return 0
65+
66+
67+
if __name__ == "__main__":
68+
raise SystemExit(main())

0 commit comments

Comments
 (0)