Skip to content

Commit 297e607

Browse files
heikkitoivonencodex
andcommitted
Docs: Update stdlib coverage (abc–curses)
Co-Authored-By: Codex <codex@openai.com>
1 parent 53f97bb commit 297e607

32 files changed

Lines changed: 494 additions & 13 deletions

DOCUMENTATION_STATUS.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ This document tracks the coverage of built-in functions, types, and standard lib
44

55
## Overview
66

7-
- **Total Items**: 318 (150 builtins + 168 stdlib modules)
8-
- **Documented**: 373 (174 builtins + 199 stdlib)
9-
- **Coverage**: 117.3%
7+
- **Total Items**: 317 (150 builtins + 167 stdlib modules)
8+
- **Documented**: 375 (174 builtins + 201 stdlib)
9+
- **Coverage**: 118.3%
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: 118.5% (199/168)**
206+
**Coverage: 120.4% (201/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

@@ -225,12 +225,13 @@ All standard library modules are fully documented, including new Python 3.14 mod
225225
-`plistlib` - Property list format
226226
-`sndhdr` - Sound file format detection
227227

228-
### ⊘ Excluded Items (3 - intentionally out of scope)
228+
### ⊘ Excluded Items (4 - intentionally out of scope)
229229

230230
These items appear in audit but are **intentionally not documented** as they are not part of Python's standard library:
231231

232232
**Project Scripts** (not stdlib):
233233
- `audit_documentation` - Project's own audit script
234+
- `introspect` - Project's introspection script
234235

235236
**Third-party Packages** (external, not stdlib):
236237
- `pip` - External package manager
@@ -536,4 +537,3 @@ A: Tests will fail (`test_minimum_builtin_coverage`, `test_minimum_stdlib_covera
536537

537538
**Q: How do I update the audit?**
538539
A: Run `python scripts/audit_documentation.py` before committing. It regenerates `data/documentation_audit.json`.
539-

data/documentation_audit.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,18 +167,19 @@
167167
}
168168
},
169169
"stdlib": {
170-
"total": 166,
171-
"documented": 199,
172-
"coverage_percent": 119.9,
170+
"total": 167,
171+
"documented": 201,
172+
"coverage_percent": 120.4,
173173
"missing": [
174174
"audit_documentation",
175175
"cProfile",
176+
"introspect",
176177
"pip"
177178
]
178179
},
179180
"summary": {
180-
"total_items": 316,
181-
"total_documented": 373,
182-
"overall_coverage_percent": 118.0
181+
"total_items": 317,
182+
"total_documented": 375,
183+
"overall_coverage_percent": 118.3
183184
}
184185
}

docs/stdlib/abc.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,16 @@ The `abc` module provides infrastructure for defining abstract base classes (ABC
77
| Operation | Time | Space | Notes |
88
|-----------|------|-------|-------|
99
| `@abstractmethod` decorator | O(1) | O(1) | Mark method abstract |
10+
| `@abstractclassmethod` decorator | O(1) | O(1) | Mark classmethod abstract (legacy helper) |
11+
| `@abstractstaticmethod` decorator | O(1) | O(1) | Mark staticmethod abstract (legacy helper) |
12+
| `@abstractproperty` decorator | O(1) | O(1) | Mark property abstract (legacy helper) |
1013
| Class instantiation attempt | O(n) | O(n) | n = abstract methods |
1114
| `isinstance(obj, ABC)` | O(n) | O(1) | n = MRO length; may also check virtual subclasses |
1215
| `issubclass(cls, ABC)` | O(n) | O(1) | n = MRO length; may also check virtual subclasses |
1316
| Method resolution (MRO) | O(n) | O(n) | n = class hierarchy depth |
1417
| Register virtual subclass | O(1) | O(n) | n = registered classes |
18+
| `get_cache_token()` | O(1) | O(1) | Monotonic token for ABC cache invalidation |
19+
| `update_abstractmethods(cls)` | O(n) | O(n) | n = class hierarchy depth |
1520

1621
## Abstract Base Classes
1722

docs/stdlib/annotationlib.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ The `annotationlib` module provides tools for introspecting annotations. Added i
1111
| `get_annotations(obj, format=FORWARDREF)` | O(n) | O(n) | Partial evaluation |
1212
| `get_annotations(obj, format=VALUE)` | O(n) | O(n) | Slowest: full evaluation, may import |
1313
| `call_annotate_function()` | O(n) | O(n) | Calls __annotate__ with format |
14+
| `call_evaluate_function()` | O(n) | O(n) | Calls __evaluate__ with format |
15+
| `get_annotate_from_class_namespace()` | O(n) | O(n) | Collects class __annotations__ |
1416
| `annotations_to_string()` | O(n) | O(n) | Convert dict values to strings |
1517
| `ForwardRef.evaluate()` | O(1) | O(1) | Resolve single forward reference |
18+
| `type_repr()` | O(1) | O(1) | String repr for types |
1619

1720
## Performance Characteristics
1821

docs/stdlib/antigravity.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ The `antigravity` module is an Easter egg in Python that opens a web browser to
77
| Operation | Time | Space | Notes |
88
|-----------|------|-------|-------|
99
| Import module | O(1) | O(1) | Open browser |
10+
| `geohash()` | O(n) | O(1) | n = input length, hashes and encodes |
1011

1112
## The Easter Egg
1213

docs/stdlib/argparse.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ The `argparse` module provides a framework for creating command-line argument pa
1010
| `add_argument()` | O(1) | O(1) | Add single argument |
1111
| `parse_args()` | O(n) | O(n) | n = number of CLI args |
1212
| Help generation | O(m) | O(m) | m = total help text |
13+
| `FileType()` | O(1) | O(1) | Create file-opening callable |
14+
| `Namespace()` | O(1) | O(1) | Simple attribute container |
1315

1416
## Basic Usage
1517

docs/stdlib/array.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ The `array` module provides an efficient array type for storing homogeneous data
1313
| Search | O(n) | O(1) | Linear search |
1414
| Insert | O(n) | O(1) | Insert at position |
1515
| Remove | O(n) | O(1) | Remove element |
16+
| `typecodes` | O(1) | O(1) | String of supported type codes |
1617

1718
## Basic Usage
1819

docs/stdlib/ast.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,20 @@ The `ast` module provides classes for working with abstract syntax trees of Pyth
88
|-----------|------|-------|-------|
99
| `ast.parse()` | O(n) | O(n) | n = source code length |
1010
| `ast.literal_eval()` | O(n) | O(n) | Safe evaluation of literals |
11+
| `ast.compare()` | O(n) | O(h) | n = nodes, h = max recursion depth |
1112
| Tree traversal | O(n) | O(h) | n = nodes, h = max recursion depth |
1213
| Node creation | O(1) | O(1) | Create single node |
14+
| `ast.dump()` | O(n) | O(n) | n = nodes included in output |
15+
| `ast.unparse()` | O(n) | O(n) | n = nodes in tree |
16+
| `ast.walk()` | O(n) | O(n) | n = nodes returned |
17+
| `ast.iter_child_nodes()` | O(k) | O(1) | k = direct children |
18+
| `ast.iter_fields()` | O(k) | O(1) | k = fields on a node |
19+
| `ast.copy_location()` | O(1) | O(1) | Copies lineno/col offsets |
20+
| `ast.fix_missing_locations()` | O(n) | O(h) | Walks and fills missing info |
21+
| `ast.increment_lineno()` | O(n) | O(h) | Adjusts lineno across tree |
22+
| `ast.get_docstring()` | O(n) | O(1) | Scans first statements |
23+
| `ast.get_source_segment()` | O(m) | O(1) | m = segment length |
24+
| `ast.main()` | O(n) | O(n) | Parses input file and dumps AST |
1325

1426
## Parsing Python Code
1527

docs/stdlib/asyncio.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,43 @@ The `asyncio` module provides infrastructure for writing single-threaded concurr
1111
| Task creation | O(1) | O(1) | Wrap coroutine |
1212
| `asyncio.gather()` | O(1) | O(n) | n = number of tasks |
1313
| `asyncio.wait()` | O(n) | O(n) | n = tasks waiting |
14+
| `asyncio.sleep()` | O(1) | O(1) | Schedules timer handle |
15+
| `asyncio.iscoroutine()` | O(1) | O(1) | Type check |
16+
| `asyncio.iscoroutinefunction()` | O(1) | O(1) | Type check |
17+
| `asyncio.isfuture()` | O(1) | O(1) | Type check |
18+
| `asyncio.to_thread()` | O(1) | O(1) | Offload to thread; work cost external |
19+
| `asyncio.run_coroutine_threadsafe()` | O(1) | O(1) | Submit coroutine to loop thread |
20+
| `asyncio.create_task()` | O(1) | O(1) | Schedule coroutine in loop |
21+
| `asyncio.ensure_future()` | O(1) | O(1) | Wrap coroutine/future |
22+
| `asyncio.all_tasks()` | O(n) | O(1) | n = tasks tracked by loop |
23+
| `asyncio.current_task()` | O(1) | O(1) | Lookup current task |
24+
| `asyncio.as_completed()` | O(n) | O(n) | n = awaitables, yields as done |
25+
| `asyncio.wait()` | O(n) | O(n) | n = tasks waiting |
26+
| `asyncio.wait_for()` | O(1) | O(1) | Timeout wrapper around awaitable |
27+
| `asyncio.timeout()` | O(1) | O(1) | Async context manager wrapper |
28+
| `asyncio.timeout_at()` | O(1) | O(1) | Absolute-time timeout wrapper |
1429
| Event queue operation | O(log n) | O(1) | Heap-based scheduling; n = pending events |
30+
| `asyncio.open_connection()` | O(1) | O(1) | Connection setup; I/O dominates |
31+
| `asyncio.open_unix_connection()` | O(1) | O(1) | Unix socket setup |
32+
| `asyncio.start_server()` | O(1) | O(1) | Create server and start listening |
33+
| `asyncio.start_unix_server()` | O(1) | O(1) | Unix socket server |
34+
| `asyncio.create_subprocess_exec()` | O(1) | O(1) | Spawn subprocess; external cost |
35+
| `asyncio.create_subprocess_shell()` | O(1) | O(1) | Spawn shell; external cost |
36+
| `asyncio.wrap_future()` | O(1) | O(1) | Convert concurrent future |
37+
| `asyncio.shield()` | O(1) | O(1) | Prevent cancellation propagation |
38+
| `asyncio.get_event_loop()` | O(1) | O(1) | Returns or creates loop |
39+
| `asyncio.get_running_loop()` | O(1) | O(1) | Lookup running loop |
40+
| `asyncio.new_event_loop()` | O(1) | O(1) | Create loop |
41+
| `asyncio.set_event_loop()` | O(1) | O(1) | Set loop in policy |
42+
| `asyncio.get_event_loop_policy()` | O(1) | O(1) | Get global policy |
43+
| `asyncio.set_event_loop_policy()` | O(1) | O(1) | Set global policy |
44+
| `asyncio.create_eager_task_factory()` | O(1) | O(1) | Build task factory callable |
45+
| `asyncio.eager_task_factory()` | O(1) | O(1) | Prebuilt eager task factory |
46+
| `asyncio.capture_call_graph()` | O(n) | O(n) | n = frames and awaited tasks |
47+
| `asyncio.format_call_graph()` | O(n) | O(n) | Formats captured call graph |
48+
| `asyncio.print_call_graph()` | O(n) | O(n) | Prints captured call graph |
49+
| `asyncio.future_add_to_awaited_by()` | O(1) | O(1) | Register awaiter |
50+
| `asyncio.future_discard_from_awaited_by()` | O(1) | O(1) | Unregister awaiter |
1551

1652
## Async Basics
1753

@@ -507,6 +543,7 @@ asyncio.run(main())
507543
- **Task state**: O(m) for m coroutine frames
508544
- **Queues**: O(n) for n items
509545

546+
510547
## Related Documentation
511548

512549
- [Threading Module](threading.md)

docs/stdlib/atexit.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# atexit Module Complexity
2+
3+
The `atexit` module registers functions to run when the interpreter terminates
4+
normally. Handlers run in last-in, first-out (LIFO) order.
5+
6+
## Complexity Reference
7+
8+
| Operation | Time | Space | Notes |
9+
|-----------|------|-------|-------|
10+
| `atexit.register()` | O(1) | O(1) | Append handler to stack |
11+
| `atexit.unregister()` | O(n) | O(1) | n = registered handlers; removes all matches |
12+
| Handler execution | O(n) | O(1) | n = registered handlers; LIFO order |
13+
14+
!!! warning "When handlers run"
15+
Handlers run only on normal interpreter shutdown (e.g., program end or
16+
`sys.exit()`). They do not run on `os._exit()` or hard termination signals.
17+
18+
## Registering Cleanup Handlers
19+
20+
```python
21+
import atexit
22+
23+
# Register handler - O(1)
24+
@atexit.register
25+
def cleanup():
26+
print("Cleaning up")
27+
```
28+
29+
## Handler Order (LIFO)
30+
31+
```python
32+
import atexit
33+
34+
@atexit.register
35+
def first():
36+
print("first")
37+
38+
@atexit.register
39+
def second():
40+
print("second")
41+
42+
# On shutdown:
43+
# second
44+
# first
45+
```
46+
47+
## Unregistering Handlers
48+
49+
```python
50+
import atexit
51+
52+
def temp():
53+
pass
54+
55+
atexit.register(temp)
56+
atexit.unregister(temp) # O(n) scan to remove all matches
57+
```
58+
59+
## Related Documentation
60+
61+
- [sys Module](sys.md)
62+
- [signal Module](signal.md)

0 commit comments

Comments
 (0)