Skip to content

Commit 975da22

Browse files
heikkitoivonencodex
andcommitted
Docs: Update stdlib p* modules and path/platform notes
Co-Authored-By: Codex <codex@openai.com>
1 parent 14c767e commit 975da22

18 files changed

Lines changed: 262 additions & 94 deletions

DOCUMENTATION_STATUS.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ This document tracks the coverage of built-in functions, types, and standard lib
55
## Overview
66

77
- **Total Items**: 317 (150 builtins + 167 stdlib modules)
8-
- **Documented**: 379 (174 builtins + 205 stdlib)
9-
- **Coverage**: 119.6%
8+
- **Documented**: 382 (174 builtins + 208 stdlib)
9+
- **Coverage**: 120.5%
1010

1111
**Note**: Coverage exceeds 100% because comprehensive documentation files (like `exceptions.md`) cover multiple individual items, and we document deprecated/removed modules for historical reference.
1212

13-
Last updated: January 27, 2026 (Python 3.14 audit)
13+
Last updated: January 30, 2026 (Python 3.14 audit)
1414

1515
## Built-in Types & Functions
1616

@@ -203,7 +203,7 @@ Complete coverage of all built-in functions, types, exceptions, and constants:
203203

204204
## Standard Library Modules
205205

206-
**Coverage: 122.8% (205/167)**
206+
**Coverage: 124.6% (208/167)**
207207

208208
All standard library modules are fully documented, including new Python 3.14 modules. Coverage exceeds 100% due to documentation of deprecated/removed modules for historical reference.
209209

@@ -305,9 +305,9 @@ All file and I/O modules now documented:
305305
-`shutil` - High-level file operations
306306
-`tempfile` - Temporary files
307307

308-
### ✅ ALL MODULES COMPLETE (205/205)
308+
### ✅ ALL MODULES COMPLETE (208/208)
309309

310-
All 102 previously undocumented stdlib modules have been added:
310+
All 105 previously undocumented stdlib modules have been added:
311311

312312
**Utilities & System (20)**
313313
-`ast` - Abstract syntax trees
@@ -359,22 +359,25 @@ All 102 previously undocumented stdlib modules have been added:
359359
-`telnetlib` - Telnet client
360360
-`xmlrpc` - XML-RPC protocol
361361

362-
**File & Path Operations (7)**
362+
**File & Path Operations (9)**
363363
-`chunk` - IFF chunk reading
364364
-`imghdr` - Image file type detection
365365
-`nturl2path` - URL to path conversion
366366
-`pipes` - Shell pipeline interface
367+
-`posix` - POSIX APIs (low-level)
367368
-`pty` - Pseudo-terminal
369+
-`pwd` - Unix password database
368370
-`tty` - Terminal control
369371
-`zipimport` - Zip import support
370372

371373
**Memory Mapping (1)**
372374
-`mmap` - Memory-mapped file access
373375

374-
**Parsing & Compilation (12)**
376+
**Parsing & Compilation (13)**
375377
-`codeop` - Compile Python source
376378
-`code` - Code evaluation
377379
-`py_compile` - Compilation
380+
-`pyexpat` - Low-level Expat XML parser
378381
-`lib2to3` - Python 2 to 3 conversion
379382
-`modulefinder` - Module dependencies
380383
-`opcode` - Python opcodes

data/documentation_audit.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@
168168
},
169169
"stdlib": {
170170
"total": 167,
171-
"documented": 205,
172-
"coverage_percent": 122.8,
171+
"documented": 208,
172+
"coverage_percent": 124.6,
173173
"missing": [
174174
"audit_documentation",
175175
"cProfile",
@@ -179,7 +179,7 @@
179179
},
180180
"summary": {
181181
"total_items": 317,
182-
"total_documented": 379,
183-
"overall_coverage_percent": 119.6
182+
"total_documented": 382,
183+
"overall_coverage_percent": 120.5
184184
}
185185
}

docs/stdlib/pathlib.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ The `pathlib` module provides an object-oriented approach to filesystem path han
77
| Method | Time | Space | Notes |
88
|--------|------|-------|-------|
99
| `Path(str)` | O(n) | O(n) | Create Path from string |
10-
| `Path.cwd()` | O(1) | O(n) | Get current directory |
11-
| `Path.home()` | O(1) | O(n) | Get home directory |
10+
| `Path.cwd()` | O(n) | O(n) | n = length of current directory |
11+
| `Path.home()` | O(n) | O(n) | n = length of home directory |
1212
| `Path.exists()` | O(1) | O(1) | Check if path exists |
1313
| `Path.is_file()` | O(1) | O(1) | Check if path is file |
1414
| `Path.is_dir()` | O(1) | O(1) | Check if path is directory |
@@ -21,10 +21,10 @@ The `pathlib` module provides an object-oriented approach to filesystem path han
2121
| `Path.stat()` | O(1) | O(1) | Get file stats |
2222
| `Path.lstat()` | O(1) | O(1) | Like stat but don't follow symlinks |
2323
| `Path.resolve()` | O(n) | O(n) | Resolve to absolute path |
24-
| `Path.absolute()` | O(1) | O(n) | Make absolute without resolving symlinks |
25-
| `Path.expanduser()` | O(1) | O(n) | Expand ~ to home directory |
26-
| `Path.iterdir()` | O(d) | O(d) | Iterate directory contents |
27-
| `Path.walk()` | O(d) | O(d) | Walk directory tree (Python 3.12+) |
24+
| `Path.absolute()` | O(n) | O(n) | Make absolute without resolving symlinks |
25+
| `Path.expanduser()` | O(n) | O(n) | Expand ~ to home directory |
26+
| `Path.iterdir()` | O(d) | O(1) per item | Iterator over directory entries |
27+
| `Path.walk()` | O(n) | O(d) | n = total entries, d = max depth |
2828
| `Path.glob(pattern)` | O(n) | O(1) per item | n = directory entries checked, returns iterator |
2929
| `Path.rglob(pattern)` | O(n) | O(1) per item | n = total tree entries, returns iterator |
3030
| `Path.mkdir()` | O(1) | O(1) | Create directory |
@@ -35,7 +35,7 @@ The `pathlib` module provides an object-oriented approach to filesystem path han
3535
| `Path.rmdir()` | O(1) | O(1) | Delete empty directory |
3636
| `Path.symlink_to(target)` | O(1) | O(1) | Create symlink |
3737
| `Path.hardlink_to(target)` | O(1) | O(1) | Create hard link |
38-
| `Path.readlink()` | O(1) | O(n) | Read symlink target |
38+
| `Path.readlink()` | O(n) | O(n) | n = length of symlink target |
3939
| `Path.chmod(mode)` | O(1) | O(1) | Change file mode |
4040
| `Path.lchmod(mode)` | O(1) | O(1) | chmod without following symlinks |
4141
| `Path.owner()` | O(1) | O(1) | Get owner name |
@@ -64,10 +64,10 @@ path = Path('/home/user/documents/file.txt') # O(27)
6464
# Relative path: O(n)
6565
path = Path('docs/README.md') # O(13)
6666

67-
# Current directory: O(1) - system call
67+
# Current directory: O(n) in path length
6868
cwd = Path.cwd()
6969

70-
# Home directory: O(1) - system call
70+
# Home directory: O(n) in path length
7171
home = Path.home()
7272
```
7373

@@ -164,7 +164,7 @@ for item in path.iterdir(): # O(d)
164164
count = sum(1 for _ in path.iterdir()) # O(d)
165165
```
166166

167-
#### Space Complexity: O(d)
167+
#### Space Complexity: O(1) per item
168168

169169
```python
170170
from pathlib import Path
@@ -293,14 +293,14 @@ path.write_bytes(b'Binary data') # O(11)
293293
path.write_text('x' * 1000000) # O(n)
294294
```
295295

296-
#### Space Complexity: O(1)
296+
#### Space Complexity: O(n)
297297

298298
```python
299299
from pathlib import Path
300300

301-
# Streaming write - no buffer needed
301+
# Encodes to bytes before writing
302302
content = 'x' * 1000000
303-
Path('file.txt').write_text(content) # O(1) extra space
303+
Path('file.txt').write_text(content) # O(n) extra space
304304
```
305305

306306
## File System Modifications
@@ -368,13 +368,13 @@ for file in Path('src').rglob('*.py'): # O(d) to find files
368368
```python
369369
from pathlib import Path
370370

371-
# Build paths: O(1) per operation
371+
# Build paths: O(n) in total path length
372372
base = Path('data')
373-
file = base / 'subdir' / 'file.txt' # O(1) per /
373+
file = base / 'subdir' / 'file.txt' # O(n)
374374

375375
# Multiple files
376376
for name in files:
377-
path = base / name # O(1) per iteration
377+
path = base / name # O(n) in path length
378378
```
379379

380380
### Safe Deletion

docs/stdlib/pdb.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ The `pdb` module provides an interactive debugger for Python code, allowing brea
66

77
| Operation | Time | Space | Notes |
88
|-----------|------|-------|-------|
9-
| `set_trace()` | O(1) | O(1) | Enter debugger |
10-
| Breakpoint | O(1) | O(1) | Register break |
11-
| Step/continue | O(1) | O(1) | Control flow |
9+
| `set_trace()` | Varies | O(1) | Setup is O(1); interactive runtime is program/user dependent |
10+
| Breakpoint | O(1) to register | O(1) | Hit checks occur during program execution |
11+
| Step/continue | Varies | O(1) | Runs until next stop; depends on code executed |
1212

1313
## Interactive Debugging
1414

@@ -18,7 +18,7 @@ The `pdb` module provides an interactive debugger for Python code, allowing brea
1818
import pdb
1919

2020
def buggy_function(x):
21-
# Enter debugger - O(1)
21+
# Enter debugger (setup is O(1); runtime depends on program/user)
2222
pdb.set_trace()
2323

2424
result = x * 2
@@ -37,7 +37,7 @@ import traceback
3737
try:
3838
1 / 0
3939
except Exception:
40-
# Debug after exception - O(1)
40+
# Debug after exception (setup is O(1); runtime depends on session)
4141
pdb.post_mortem()
4242
```
4343

docs/stdlib/pickle.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ data = {'name': 'Alice', 'age': 30, 'scores': [95, 87, 92]}
2525
# Serialize to bytes - O(n) where n = object size
2626
pickled = pickle.dumps(data)
2727
print(type(pickled)) # <class 'bytes'>
28-
print(len(pickled)) # ~50 bytes
28+
print(len(pickled)) # Size varies by protocol and data
2929

3030
# Deserialize from bytes - O(n)
3131
restored = pickle.loads(pickled)
@@ -57,29 +57,29 @@ import pickle
5757

5858
obj = {'a': 1, 'b': [2, 3, 4]}
5959

60-
# Protocol 0 (ASCII, human-readable) - O(n) slowest
60+
# Protocol 0 (ASCII, human-readable) - O(n)
6161
p0 = pickle.dumps(obj, protocol=0)
62-
print(len(p0)) # Largest
62+
print(len(p0)) # Often largest, but varies by object
6363

6464
# Protocol 1 (Binary, old) - O(n)
6565
p1 = pickle.dumps(obj, protocol=1)
66-
print(len(p1)) # Smaller
66+
print(len(p1)) # Often smaller than protocol 0
6767

6868
# Protocol 2 (Binary, Python 2.3+) - O(n)
6969
p2 = pickle.dumps(obj, protocol=2)
70-
print(len(p2)) # Smaller still
70+
print(len(p2)) # Often smaller than protocol 1
7171

7272
# Protocol 3 (Binary, Python 3.0+) - O(n)
7373
p3 = pickle.dumps(obj, protocol=3)
74-
print(len(p3)) # Even smaller
74+
print(len(p3)) # Often smaller than protocol 2
7575

76-
# Protocol 4 (Binary, Python 3.4+) - O(n) faster
76+
# Protocol 4 (Binary, Python 3.4+) - O(n)
7777
p4 = pickle.dumps(obj, protocol=4)
78-
print(len(p4)) # Optimized
78+
print(len(p4)) # Often more compact for many objects
7979

80-
# Protocol 5 (Binary, Python 3.8+) - O(n) fastest
80+
# Protocol 5 (Binary, Python 3.8+) - O(n)
8181
p5 = pickle.dumps(obj, protocol=5)
82-
print(len(p5)) # Smallest and fastest
82+
print(len(p5)) # Supports out-of-band buffers; size varies
8383
```
8484

8585
### Default Protocol
@@ -216,15 +216,15 @@ class Team:
216216
self.name = name
217217
self.members = members # List of dicts
218218

219-
# Pickle nested structure - O(n*m)
219+
# Pickle nested structure - O(n) in total object graph size
220220
team = Team('Team A', [
221221
{'name': 'Alice', 'role': 'lead'},
222222
{'name': 'Bob', 'role': 'dev'}
223223
])
224224

225225
pickled = pickle.dumps(team)
226226

227-
# Unpickle - O(n*m)
227+
# Unpickle - O(n) in total object graph size
228228
restored = pickle.loads(pickled)
229229
print(restored.name) # 'Team A'
230230
print(restored.members[0]) # {'name': 'Alice', ...}
@@ -267,11 +267,11 @@ large_list = list(range(1000000))
267267
# Method 1: dumps - creates bytes in memory - O(n) space
268268
data_bytes = pickle.dumps(large_list) # Large memory usage
269269

270-
# Method 2: dump to file - streams output - O(n) time, O(1) space
270+
# Method 2: dump to file - streams output - O(n) time, O(n) space for memoization
271271
with open('large.pkl', 'wb') as f:
272272
pickle.dump(large_list, f) # Much more memory efficient
273273

274-
# Method 3: Pickler with file - O(n) time, O(1) space
274+
# Method 3: Pickler with file - O(n) time, O(n) space for memoization
275275
with open('large.pkl', 'wb') as f:
276276
pickler = pickle.Pickler(f)
277277
pickler.dump(large_list)
@@ -395,7 +395,7 @@ restored = dill.loads(pickled)
395395
- **Protocol 0**: Slowest, largest, ASCII (rarely use)
396396
- **Protocol 1-2**: Legacy compatibility
397397
- **Protocol 3**: Default Python 3, good balance
398-
- **Protocol 4+**: Better compression, faster for large objects
398+
- **Protocol 4+**: More compact encoding (no compression), often faster for large objects
399399

400400
## Best Practices
401401

docs/stdlib/pkgutil.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ The `pkgutil` module provides utilities for working with packages and module sea
66

77
| Operation | Time | Space | Notes |
88
|-----------|------|-------|-------|
9-
| `iter_modules(path)` | O(n) | O(n) | n = modules in path |
10-
| `walk_packages()` | O(n) | O(n) | n = all subpackages |
11-
| `find_loader(name)` | O(1) avg, O(n) worst | O(1) | Check sys.modules; O(n) worst case due to hash collisions |
12-
| `get_data(name)` | O(n) | O(n) | n = file size |
13-
| `extend_path()` | O(n) | O(n) | n = path entries |
9+
| `iter_modules(path)` | O(n) | O(1) per item | n = modules in path |
10+
| `walk_packages()` | O(n) | O(n) | n = all subpackages/modules (tracks seen paths) |
11+
| `find_spec(name)` | O(1) avg, O(p) worst | O(1) | p = sys.meta_path length (import hooks) |
12+
| `get_data(name)` | O(n) | O(n) | n = file size (plus import overhead) |
13+
| `extend_path()` | O(p + k) | O(p + k) | p = search path entries, k = .pkg entries |
1414

1515
## Common Operations
1616

docs/stdlib/platform.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ The `platform` module provides functions to access platform-specific information
66

77
| Operation | Time | Space | Notes |
88
|-----------|------|-------|-------|
9-
| `platform()` | O(1) | O(1) | Cached after first call |
10-
| `system()` | O(1) | O(1) | Cached after first call |
11-
| `release()` | O(1) | O(1) | Cached after first call |
12-
| `version()` | O(1) | O(1) | Cached after first call |
13-
| `machine()` | O(1) | O(1) | Cached after first call |
14-
| `node()` | O(1) | O(1) | Cached after first call; first call may involve syscall |
9+
| `platform()` | O(1) cached, O(n) first | O(n) | n = length of result string |
10+
| `system()` | O(1) cached, O(n) first | O(n) | Derived from uname |
11+
| `release()` | O(1) cached, O(n) first | O(n) | Derived from uname |
12+
| `version()` | O(1) cached, O(n) first | O(n) | Derived from uname |
13+
| `machine()` | O(1) cached, O(n) first | O(n) | Derived from uname |
14+
| `node()` | O(1) cached, O(n) first | O(n) | Hostname length |
1515
| `python_version()` | O(1) | O(1) | Static value |
16-
| `uname()` | O(1) | O(1) | Cached after first call |
16+
| `uname()` | O(1) cached, O(n) first | O(n) | n = total size of fields |
1717

1818
## Common Operations
1919

@@ -22,20 +22,20 @@ The `platform` module provides functions to access platform-specific information
2222
```python
2323
import platform
2424

25-
# O(1) - get operating system name
25+
# O(1) after cache; first call O(n)
2626
os_name = platform.system() # 'Linux', 'Windows', 'Darwin'
2727

28-
# O(1) - get OS release
28+
# O(1) after cache; first call O(n)
2929
os_release = platform.release() # '5.15.0-1234-generic'
3030

31-
# O(1) - get OS version
31+
# O(1) after cache; first call O(n)
3232
os_version = platform.version()
3333
# '#1234-Ubuntu SMP ...'
3434

35-
# O(1) - get machine architecture
35+
# O(1) after cache; first call O(n)
3636
machine = platform.machine() # 'x86_64', 'arm64'
3737

38-
# O(1) - get hostname
38+
# O(1) after cache; first call O(n)
3939
hostname = platform.node() # 'mycomputer'
4040
```
4141

@@ -64,15 +64,15 @@ compiler = platform.python_compiler()
6464
```python
6565
import platform
6666

67-
# O(1) - get complete platform description
67+
# O(1) after cache; first call O(n)
6868
platform_str = platform.platform()
6969
# 'Linux-5.15.0-1234-generic-x86_64-with-glibc2.35'
7070

71-
# O(1) - with detailed version
71+
# O(1) after cache; first call O(n)
7272
detailed = platform.platform(aliased=True)
7373
# Uses common OS aliases like 'Ubuntu' instead of 'Linux'
7474

75-
# O(1) - with specific details
75+
# O(1) after cache; first call O(n)
7676
custom = platform.platform(aliased=True, terse=True)
7777
```
7878

@@ -81,7 +81,7 @@ custom = platform.platform(aliased=True, terse=True)
8181
```python
8282
import platform
8383

84-
# O(1) - get uname data (Unix-like systems)
84+
# O(1) after cache; first call O(n)
8585
uname_info = platform.uname()
8686
# Returns: (system, node, release, version, machine, processor)
8787

0 commit comments

Comments
 (0)