Skip to content

Commit 16932a6

Browse files
heikkitoivonencodex
andcommitted
Docs: Continue stdlib coverage (dataclasses–doctest)
Co-Authored-By: Codex <codex@openai.com>
1 parent 297e607 commit 16932a6

7 files changed

Lines changed: 86 additions & 0 deletions

File tree

docs/stdlib/dataclasses.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ The `dataclasses` module provides a decorator to automatically generate special
1414
| `replace()` | O(n) | O(n) | Creates new instance |
1515
| `asdict()` | O(n*m) | O(n*m) | n = fields, m = nesting depth; recursive |
1616
| `astuple()` | O(n*m) | O(n*m) | n = fields, m = nesting depth; recursive |
17+
| `fields()` | O(n) | O(n) | n = number of fields |
18+
| `field()` | O(1) | O(1) | Field factory |
19+
| `make_dataclass()` | O(n) | O(n) | n = number of fields |
20+
| `is_dataclass()` | O(1) | O(1) | Type check |
21+
| `Field` | O(1) | O(1) | Field descriptor |
22+
| `InitVar` | O(1) | O(1) | Init-only variable wrapper |
23+
| `KW_ONLY` | O(1) | O(1) | Keyword-only marker |
24+
| `MISSING` | O(1) | O(1) | Sentinel for no default |
25+
| `FrozenInstanceError` | O(1) | O(1) | Exception type |
1726

1827
## Basic Dataclass
1928

docs/stdlib/datetime.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ The `datetime` module provides classes for manipulating dates and times.
3535
| `date.timetuple()` | O(1) | O(1) | time.struct_time |
3636
| `date.toordinal()` | O(1) | O(1) | Proleptic Gregorian ordinal |
3737
| `date.replace(year=...)` | O(1) | O(1) | Return new date |
38+
| `date.__format__(fmt)` | O(n) | O(n) | Format string length n |
3839

3940
## Datetime Operations
4041

@@ -50,6 +51,16 @@ The `datetime` module provides classes for manipulating dates and times.
5051
| `datetime.dst()` | O(1) | O(1) | Daylight saving offset |
5152
| `datetime.tzname()` | O(1) | O(1) | Timezone name string |
5253
| `datetime.utcoffset()` | O(1) | O(1) | UTC offset as timedelta |
54+
| `datetime.astimezone()` | O(1) | O(1) | Convert between timezones |
55+
| `datetime.now(tz)` | O(1) | O(1) | Current datetime in tz |
56+
| `datetime.utcnow()` | O(1) | O(1) | Current UTC datetime |
57+
| `datetime.utcfromtimestamp(ts)` | O(1) | O(1) | From timestamp (UTC) |
58+
| `datetime.fromtimestamp(ts, tz)` | O(1) | O(1) | From timestamp with tz |
59+
| `datetime.replace(...)` | O(1) | O(1) | New datetime with fields replaced |
60+
| `datetime.timetuple()` | O(1) | O(1) | time.struct_time |
61+
| `datetime.ctime()` | O(1) | O(1) | C-style string |
62+
| `datetime.isoformat()` | O(1) | O(1) | ISO 8601 string |
63+
| `datetime.__format__()` | O(n) | O(n) | Format string length n |
5364

5465
## Time Operations
5566

@@ -63,6 +74,7 @@ The `datetime` module provides classes for manipulating dates and times.
6374
| `time.dst()` | O(1) | O(1) | Daylight saving offset |
6475
| `time.tzname()` | O(1) | O(1) | Timezone name string |
6576
| `time.utcoffset()` | O(1) | O(1) | UTC offset as timedelta |
77+
| `time.fold` | O(1) | O(1) | Attribute access |
6678

6779
## Timedelta Operations
6880

@@ -73,6 +85,26 @@ The `datetime` module provides classes for manipulating dates and times.
7385
| `td1 + td2` | O(1) | O(1) | Add durations |
7486
| `td1 - td2` | O(1) | O(1) | Subtract durations |
7587
| `td * n` | O(1) | O(1) | Multiply duration |
88+
| `td / n` | O(1) | O(1) | Divide duration |
89+
| `td // n` | O(1) | O(1) | Floor divide duration |
90+
| `abs(td)` | O(1) | O(1) | Absolute duration |
91+
| `-td` | O(1) | O(1) | Negate duration |
92+
93+
## Timezone Utilities
94+
95+
| Operation | Time | Space | Notes |
96+
|-----------|------|-------|-------|
97+
| `timezone(offset)` | O(1) | O(1) | Fixed offset tzinfo |
98+
| `timezone.utc` | O(1) | O(1) | UTC tzinfo singleton |
99+
| `UTC` | O(1) | O(1) | UTC tzinfo alias |
100+
| `tzinfo` | O(1) | O(1) | Abstract base for tzinfo |
101+
102+
## Constants
103+
104+
| Name | Time | Space | Notes |
105+
|------|------|-------|-------|
106+
| `MINYEAR` / `MAXYEAR` | O(1) | O(1) | Supported year bounds |
107+
| `datetime_CAPI` | O(1) | O(1) | C API capsule |
76108

77109
## Common Operations
78110

docs/stdlib/dbm.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ The `dbm` module provides interfaces to various Unix database implementations, a
1313
| `key in db` | O(1) to O(log n) | O(1) | Backend-dependent |
1414
| `db.keys()` | O(n) | O(n) | Get all keys (slow) |
1515
| `db.close()` | O(n) | O(1) | Flush and close |
16+
| `whichdb()` | O(1) | O(1) | Detect backend type |
17+
| `error` | O(1) | O(1) | Exception type |
1618

1719
## DBM Variants
1820

docs/stdlib/decimal.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,17 @@ The `decimal` module provides support for decimal floating point arithmetic with
4040
| `next_plus()` / `next_minus()` | O(n) | O(n) | Next representable value |
4141
| `next_toward(other)` | O(n) | O(n) | Next value toward other |
4242
| `remainder_near(other)` | O(n²) | O(n) | IEEE remainder |
43+
| `getcontext()` | O(1) | O(1) | Get current context |
44+
| `setcontext(ctx)` | O(1) | O(1) | Set current context |
45+
| `localcontext([ctx])` | O(1) | O(1) | Context manager |
46+
| `Context()` | O(1) | O(1) | Create context |
47+
| `DecimalTuple` | O(1) | O(1) | Tuple of sign/digits/exponent |
48+
| `DefaultContext` / `BasicContext` / `ExtendedContext` | O(1) | O(1) | Predefined contexts |
49+
| `IEEEContext()` | O(1) | O(1) | IEEE 754 context |
50+
| Signals/flags | O(1) | O(1) | `Inexact`, `Rounded`, `Underflow`, `Overflow`, `Subnormal`, `Clamped` |
51+
| Exceptions | O(1) | O(1) | `DecimalException`, `InvalidOperation`, `DivisionByZero`, etc. |
52+
| Rounding modes | O(1) | O(1) | `ROUND_HALF_EVEN`, `ROUND_UP`, etc. |
53+
| Limits | O(1) | O(1) | `MAX_PREC`, `MAX_EMAX`, `MIN_EMIN`, `MIN_ETINY` |
4354

4455
## Creating Decimal Objects
4556

docs/stdlib/difflib.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ The `difflib` module provides tools for comparing sequences (lists, strings) and
1414
| `unified_diff()` | O(n+m) | O(n+m) | Generate unified diff |
1515
| `context_diff()` | O(n+m) | O(n+m) | Generate context diff |
1616
| `ndiff()` | O(n+m) | O(n+m) | Generate detailed diff |
17+
| `diff_bytes()` | O(n+m) | O(n+m) | Generate diff over bytes |
18+
| `get_close_matches()` | O(n*m) | O(n) | n = possibilities, m = word length |
19+
| `restore()` | O(n) | O(n) | Reconstruct sequence from diff |
20+
| `Differ()` | O(1) | O(1) | Create differ |
21+
| `HtmlDiff()` | O(1) | O(1) | Create HTML differ |
22+
| `Match` | O(1) | O(1) | Named tuple for match blocks |
23+
| `IS_CHARACTER_JUNK` / `IS_LINE_JUNK` | O(1) | O(1) | Default junk filters |
1724

1825
## Sequence Matching
1926

docs/stdlib/dis.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,19 @@ The `dis` module provides tools to disassemble Python bytecode. It shows the low
99
| `dis.dis()` | O(n) | O(n) | n = bytecode instructions |
1010
| `dis.get_instructions()` | O(n) | O(n) | Iterate bytecode |
1111
| Bytecode analysis | O(n) | O(1) | Single pass |
12+
| `dis.Bytecode()` | O(1) | O(1) | Create Bytecode wrapper |
13+
| `dis.code_info()` | O(n) | O(n) | Format code object metadata |
14+
| `dis.show_code()` | O(n) | O(n) | Print code metadata |
15+
| `dis.stack_effect()` | O(1) | O(1) | Stack effect for opcode |
16+
| `dis.findlinestarts()` | O(n) | O(n) | Map bytecode to lines |
17+
| `dis.findlabels()` | O(n) | O(n) | Find jump targets |
18+
| `dis.pretty_flags()` | O(n) | O(n) | Format compiler flags |
19+
| `dis.get_executor()` | O(1) | O(1) | Return current executor |
20+
| `dis.print_instructions()` | O(n) | O(n) | Print Instruction list |
21+
| `dis.disassemble()` | O(n) | O(n) | Disassemble code object |
22+
| `dis.disco()` / `dis.distb()` | O(n) | O(n) | Disassemble object/traceback |
23+
| `dis.main()` | O(n) | O(n) | CLI entrypoint |
24+
| `Instruction` / `Positions` | O(1) | O(1) | Named tuple types |
1225

1326
## Disassembling Functions
1427

docs/stdlib/doctest.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@ The `doctest` module finds and runs tests embedded in docstrings. It extracts ex
99
| `doctest.testmod()` | O(n) | O(n) | n = docstring lines |
1010
| Example extraction | O(n) | O(n) | Parse docstrings |
1111
| Test execution | O(k) | O(1) | k = number of examples |
12+
| `testfile()` | O(n) | O(n) | n = file size |
13+
| `DocTestRunner()` | O(1) | O(1) | Runner setup |
14+
| `DocTestParser()` | O(1) | O(1) | Parser setup |
15+
| `DocTestFinder()` | O(n) | O(n) | Find doc tests in objects |
16+
| `run_docstring_examples()` | O(n) | O(1) | Execute examples |
17+
| `script_from_examples()` | O(n) | O(n) | Generate script from docs |
18+
| `testsource()` | O(n) | O(n) | Extract source from docstring |
19+
| `debug()` / `debug_script()` / `debug_src()` | O(n) | O(n) | Debug helpers |
20+
| `register_optionflag()` | O(1) | O(1) | Register option flag |
21+
| `set_unittest_reportflags()` | O(1) | O(1) | Configure unittest output |
22+
| `DocTest` / `Example` | O(1) | O(1) | Data structures |
23+
| `DocTestFailure` / `UnexpectedException` | O(1) | O(1) | Exception types |
1224

1325
## Running Doctests
1426

0 commit comments

Comments
 (0)