Skip to content

Commit 2a10d79

Browse files
heikkitoivonencodex
andcommitted
Docs: Update stdlib gc-gzip
Co-Authored-By: Codex <codex@openai.com>
1 parent 1ba0a31 commit 2a10d79

11 files changed

Lines changed: 160 additions & 44 deletions

File tree

DOCUMENTATION_STATUS.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ 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**: 376 (174 builtins + 202 stdlib)
9-
- **Coverage**: 118.6%
8+
- **Documented**: 377 (174 builtins + 203 stdlib)
9+
- **Coverage**: 118.9%
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

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

204204
## Standard Library Modules
205205

206-
**Coverage: 121.0% (202/167)**
206+
**Coverage: 121.6% (203/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,15 +305,16 @@ All file and I/O modules now documented:
305305
-`shutil` - High-level file operations
306306
-`tempfile` - Temporary files
307307

308-
### ✅ ALL MODULES COMPLETE (202/202)
308+
### ✅ ALL MODULES COMPLETE (203/203)
309309

310310
All 100 previously undocumented stdlib modules have been added:
311311

312-
**Utilities & System (19)**
312+
**Utilities & System (20)**
313313
-`ast` - Abstract syntax trees
314314
-`dis` - Disassembler for bytecode
315315
-`doctest` - Testing via docstrings
316316
-`errno` - Error number constants
317+
-`gc` - Garbage collection interface
317318
-`getopt` - Command-line option parsing
318319
-`gettext` - Internationalization
319320
-`keyword` - Python keywords

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": 202,
172-
"coverage_percent": 121.0,
171+
"documented": 203,
172+
"coverage_percent": 121.6,
173173
"missing": [
174174
"audit_documentation",
175175
"cProfile",
@@ -179,7 +179,7 @@
179179
},
180180
"summary": {
181181
"total_items": 317,
182-
"total_documented": 376,
183-
"overall_coverage_percent": 118.6
182+
"total_documented": 377,
183+
"overall_coverage_percent": 118.9
184184
}
185185
}

docs/stdlib/gc.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# gc Module
2+
3+
The `gc` module provides access to the garbage collector for tracking and controlling cyclic
4+
references in Python.
5+
6+
## Complexity Reference
7+
8+
| Operation | Time | Space | Notes |
9+
|-----------|------|-------|-------|
10+
| `enable()` | O(1) | O(1) | Enable cyclic GC |
11+
| `disable()` | O(1) | O(1) | Disable cyclic GC |
12+
| `isenabled()` | O(1) | O(1) | Check GC status |
13+
| `collect()` | O(n) | O(n) | n = tracked objects |
14+
| `set_threshold()` | O(1) | O(1) | Update generation thresholds |
15+
| `get_threshold()` | O(1) | O(1) | Read thresholds |
16+
| `get_count()` | O(1) | O(1) | Generation allocation counts |
17+
| `get_stats()` | O(1) | O(1) | GC stats per generation |
18+
| `set_debug()` | O(1) | O(1) | Set debug flags |
19+
| `get_debug()` | O(1) | O(1) | Read debug flags |
20+
| `get_objects()` | O(n) | O(n) | Return tracked objects |
21+
| `get_referrers()` | O(n) | O(n) | Find objects referring to targets |
22+
| `get_referents()` | O(n) | O(n) | Find objects referenced by targets |
23+
| `is_tracked()` | O(1) | O(1) | Check GC tracking |
24+
| `is_finalized()` | O(1) | O(1) | Check finalization state |
25+
| `freeze()` | O(n) | O(n) | Freeze tracked objects |
26+
| `unfreeze()` | O(n) | O(n) | Unfreeze tracked objects |
27+
| `get_freeze_count()` | O(1) | O(1) | Count frozen objects |
28+
29+
## Common Operations
30+
31+
### Trigger Collection
32+
33+
```python
34+
import gc
35+
36+
# Force collection - O(n)
37+
collected = gc.collect()
38+
print(collected)
39+
```
40+
41+
### Enable or Disable GC
42+
43+
```python
44+
import gc
45+
46+
# Disable cyclic GC - O(1)
47+
gc.disable()
48+
49+
# Enable cyclic GC - O(1)
50+
gc.enable()
51+
52+
# Check state - O(1)
53+
if gc.isenabled():
54+
print("GC enabled")
55+
```
56+
57+
### Inspect Thresholds and Counters
58+
59+
```python
60+
import gc
61+
62+
thresholds = gc.get_threshold() # O(1)
63+
counts = gc.get_count() # O(1)
64+
```
65+
66+
### Reference Inspection
67+
68+
```python
69+
import gc
70+
71+
obj = []
72+
referrers = gc.get_referrers(obj) # O(n)
73+
referents = gc.get_referents(obj) # O(n)
74+
```
75+
76+
## Debugging Flags
77+
78+
Common flags include:
79+
80+
- `DEBUG_STATS`
81+
- `DEBUG_COLLECTABLE`
82+
- `DEBUG_UNCOLLECTABLE`
83+
- `DEBUG_SAVEALL`
84+
- `DEBUG_LEAK`
85+
86+
## Related Documentation
87+
88+
- [sys Module](sys.md)
89+
- [weakref Module](weakref.md)

docs/stdlib/genericpath.md

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,52 +6,24 @@ The `genericpath` module provides generic pathname utilities shared by `posixpat
66

77
| Operation | Time | Space | Notes |
88
|-----------|------|-------|-------|
9-
| `commonpath(list)` | O(n*m) | O(n) | Find common path prefix |
109
| `commonprefix(list)` | O(n*m) | O(n) | Find common string prefix |
1110
| `exists(path)` | O(1) | O(1) | Check if path exists |
11+
| `lexists(path)` | O(1) | O(1) | Check if path exists (even if broken symlink) |
1212
| `isfile(path)` | O(1) | O(1) | Check if file |
1313
| `isdir(path)` | O(1) | O(1) | Check if directory |
1414
| `islink(path)` | O(1) | O(1) | Check if symlink |
15+
| `isjunction(path)` | O(1) | O(1) | Check Windows junction |
16+
| `isdevdrive(path)` | O(1) | O(1) | Check Windows Dev Drive |
1517
| `getsize(path)` | O(1) | O(1) | Get file size |
1618
| `getmtime(path)` | O(1) | O(1) | Get modification time |
1719
| `getatime(path)` | O(1) | O(1) | Get access time |
1820
| `getctime(path)` | O(1) | O(1) | Get creation time |
21+
| `samefile(a, b)` | O(1) | O(1) | Compare underlying file identity |
22+
| `samestat(stat1, stat2)` | O(1) | O(1) | Compare stat results |
23+
| `sameopenfile(fd1, fd2)` | O(1) | O(1) | Compare open file descriptors |
1924

2025
## Path Comparison
2126

22-
### commonpath()
23-
24-
#### Time Complexity: O(n*m)
25-
26-
Where n = number of paths, m = length of shortest path.
27-
28-
```python
29-
import genericpath
30-
31-
# Find common path: O(n*m)
32-
paths = ['/home/user/docs', '/home/user/downloads', '/home/user/desktop']
33-
common = genericpath.commonpath(paths) # O(n*m)
34-
# Result: '/home/user'
35-
36-
# Single path
37-
common = genericpath.commonpath(['/home/user/file']) # O(1)
38-
# Result: '/home/user/file'
39-
40-
# No common path
41-
common = genericpath.commonpath(['/home', '/var', '/usr']) # O(n*m)
42-
# Result: '/'
43-
```
44-
45-
#### Space Complexity: O(n)
46-
47-
```python
48-
import genericpath
49-
50-
# Result and temporary storage
51-
paths = ['/path1', '/path2', '/path3']
52-
common = genericpath.commonpath(paths) # O(n) space for result
53-
```
54-
5527
### commonprefix()
5628

5729
#### Time Complexity: O(n*m)
@@ -82,9 +54,23 @@ paths = ['a' * 1000, 'a' * 1000, 'b' * 1000]
8254
prefix = genericpath.commonprefix(paths) # O(m) space for result
8355
```
8456

57+
File identity helpers can compare paths or stat results:
58+
59+
```python
60+
import genericpath
61+
import os
62+
63+
same = genericpath.samefile("a.txt", "b.txt") # O(1)
64+
same = genericpath.sameopenfile(os.open("a.txt", os.O_RDONLY),
65+
os.open("a.txt", os.O_RDONLY)) # O(1)
66+
stat1 = os.stat("a.txt")
67+
stat2 = os.stat("b.txt")
68+
same = genericpath.samestat(stat1, stat2) # O(1)
69+
```
70+
8571
## Path Existence and Type Checks
8672

87-
### exists(), isfile(), isdir()
73+
### exists(), lexists(), isfile(), isdir()
8874

8975
#### Time Complexity: O(1)
9076

@@ -95,6 +81,9 @@ import genericpath
9581
if genericpath.exists('/path/to/file'): # O(1) stat
9682
print('exists')
9783

84+
if genericpath.lexists('/path/to/maybe-link'): # O(1) lstat
85+
print('exists (even if broken symlink)')
86+
9887
if genericpath.isfile('/path/to/file'): # O(1) stat
9988
print('is file')
10089

@@ -136,6 +125,18 @@ import genericpath
136125
is_link = genericpath.islink('/path') # O(1) space
137126
```
138127

128+
Windows-only checks also include junctions and Dev Drives:
129+
130+
```python
131+
import genericpath
132+
133+
if genericpath.isjunction('C:\\\\path\\\\to\\\\junction'): # O(1)
134+
print('is junction')
135+
136+
if genericpath.isdevdrive('C:\\\\path'): # O(1)
137+
print('is dev drive')
138+
```
139+
139140
## File Statistics
140141

141142
### getsize(), getmtime(), getatime(), getctime()
@@ -328,6 +329,8 @@ size = stat_info.st_size
328329
# Both O(1), os.stat more flexible
329330
```
330331

332+
`ALLOW_MISSING` is a public sentinel used by `os.path.realpath()` to allow missing path components.
333+
331334
## Platform Independence
332335

333336
```python
@@ -340,6 +343,7 @@ exists = genericpath.exists(path) # O(1) on any platform
340343
size = genericpath.getsize(path) # O(1) on any platform
341344
```
342345

346+
343347
## Version Notes
344348

345349
- **Python 3.x**: Full Unicode support

docs/stdlib/getopt.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ The `getopt` module provides command-line argument parsing using the GNU getopt(
77
| Operation | Time | Space | Notes |
88
|-----------|------|-------|-------|
99
| `getopt.getopt()` | O(n) | O(n) | n = command-line args |
10+
| `getopt.gnu_getopt()` | O(n) | O(n) | GNU-style parsing |
1011
| Argument parsing | O(n) | O(n) | Parse and store |
1112

1213
## Parsing Command-Line Arguments
@@ -35,6 +36,7 @@ for opt, arg in opts:
3536
print(f"Version: {arg}")
3637
```
3738

39+
3840
## Related Documentation
3941

4042
- [argparse Module](argparse.md)

docs/stdlib/getpass.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ The `getpass` module provides utilities for prompting the user for passwords wit
88
|-----------|------|-------|-------|
99
| `getpass()` | O(n) | O(n) | n = password length |
1010
| `getuser()` | O(1) | O(1) | Get current user |
11+
| `fallback_getpass()` | O(n) | O(n) | Fallback prompt (echoed) |
12+
| `unix_getpass()` | O(n) | O(n) | Unix-specific prompt |
13+
| `win_getpass()` | O(n) | O(n) | Windows-specific prompt |
1114

1215
## Common Operations
1316

@@ -27,6 +30,9 @@ password = getpass.getpass(prompt="Enter secret: ")
2730
# Input is not echoed to screen
2831
```
2932

33+
If terminal control isn't available, `getpass()` may fall back to `fallback_getpass()` and raise
34+
`GetPassWarning`. Platform-specific helpers `unix_getpass()` and `win_getpass()` are also exposed.
35+
3036
### Getting Current User
3137

3238
```python

docs/stdlib/gettext.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ The `gettext` module provides internationalization (i18n) support for Python app
77
| Operation | Time | Space | Notes |
88
|-----------|------|-------|-------|
99
| `gettext.install()` | O(n) | O(n) | Load translations |
10+
| `translation()` | O(n) | O(n) | Load translation catalog |
11+
| `find()` | O(n) | O(1) | Locate translation file |
12+
| `bindtextdomain()` | O(1) | O(1) | Set global locale dir |
13+
| `textdomain()` | O(1) | O(1) | Set default domain |
1014
| Message lookup | O(1) | O(1) | Hash-based dict |
1115
| `ngettext()` | O(1) | O(1) | Plural form selection |
1216

docs/stdlib/glob.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ The `glob` module provides Unix shell-style pathname expansion using wildcard pa
1010
| `iglob()` function | O(1) init | O(1) per item | Iterator, lazy evaluation |
1111
| Pattern matching | O(n) | O(1) | n = files in directory |
1212
| Recursive search `**` | O(d) | O(1) per file | d = depth of directory tree |
13+
| `escape()` | O(n) | O(n) | Escape metacharacters |
14+
| `has_magic()` | O(n) | O(1) | Detect pattern magic |
15+
| `glob0()` | O(1) | O(1) | Single-directory literal/implicit match |
16+
| `glob1()` | O(n) | O(n) | One-level pattern match |
17+
| `translate()` | O(n) | O(n) | Convert glob to regex |
1318

1419
## Basic Globbing
1520

@@ -234,6 +239,7 @@ pattern = glob.escape(filename)
234239
result = glob.glob(pattern)
235240
```
236241

242+
237243
## Common Use Cases
238244

239245
### Find Recent Files

docs/stdlib/graphlib.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ The `graphlib` module provides a topological sort implementation for resolving d
1212
| `get_ready()` | O(1) amortized | O(k) | Get all ready nodes as tuple, k = ready count |
1313
| `done(node)` | O(d) | O(1) | Mark done, d = node degree |
1414
| `static_order()` | O(v + e) | O(v + e) | Complete topological sort |
15+
| `CycleError` | O(1) | O(1) | Exception raised on cycles |
1516

1617
## Basic Topological Sort
1718

docs/stdlib/gzip.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ The `gzip` module provides GZIP compression and decompression functionality.
1111
| `GzipFile.write(data)` | O(n) | O(k) | Compress and write, n = input size, k = buffer |
1212
| `compress(data)` | O(n) | O(n) | Compress bytes (DEFLATE is linear in practice) |
1313
| `decompress(data)` | O(m) | O(m) | Decompress bytes |
14+
| `GzipFile()` | O(1) | O(1) | Create file object |
15+
| `BadGzipFile` | O(1) | O(1) | Exception for invalid gzip data |
1416

1517
## Opening Files
1618

0 commit comments

Comments
 (0)