Skip to content

Commit 4e3209c

Browse files
heikkitoivonencodex
andcommitted
Docs: Update stdlib docs (u-z)
Co-Authored-By: Codex <codex@openai.com>
1 parent 50e3748 commit 4e3209c

13 files changed

Lines changed: 156 additions & 136 deletions

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**: 313 (150 builtins + 163 stdlib modules)
8-
- **Documented**: 386 (174 builtins + 212 stdlib)
9-
- **Coverage**: 123.3%
8+
- **Documented**: 387 (174 builtins + 213 stdlib)
9+
- **Coverage**: 123.6%
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: 130.1% (212/163)**
206+
**Coverage: 130.7% (213/163)**
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

@@ -312,11 +312,11 @@ All file and I/O modules now documented:
312312
-`shutil` - High-level file operations
313313
-`tempfile` - Temporary files
314314

315-
### ✅ ALL MODULES COMPLETE (212/212)
315+
### ✅ ALL MODULES COMPLETE (213/213)
316316

317317
All 108 previously undocumented stdlib modules have been added:
318318

319-
**Utilities & System (23)**
319+
**Utilities & System (24)**
320320
-`ast` - Abstract syntax trees
321321
-`dis` - Disassembler for bytecode
322322
-`doctest` - Testing via docstrings
@@ -419,6 +419,7 @@ All 108 previously undocumented stdlib modules have been added:
419419
-`compileall` - Batch compilation
420420
-`rlcompleter` - Readline completion
421421
-`tabnanny` - Python indentation checker
422+
-`unicodedata` - Unicode character database
422423
-`this` - Zen of Python
423424
-`readline` - Line-editing support
424425

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": 163,
171-
"documented": 212,
172-
"coverage_percent": 130.1,
171+
"documented": 213,
172+
"coverage_percent": 130.7,
173173
"missing": [
174174
"audit_documentation",
175175
"cProfile",
@@ -179,7 +179,7 @@
179179
},
180180
"summary": {
181181
"total_items": 313,
182-
"total_documented": 386,
183-
"overall_coverage_percent": 123.3
182+
"total_documented": 387,
183+
"overall_coverage_percent": 123.6
184184
}
185185
}

docs/stdlib/unicodedata.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# unicodedata Module
2+
3+
The `unicodedata` module provides access to the Unicode Character Database (UCD),
4+
including character names, categories, normalization, and digit/decimal values.
5+
6+
## Complexity Reference
7+
8+
| Operation | Time | Space | Notes |
9+
|-----------|------|-------|-------|
10+
| `name(ch)` | O(1) | O(1) | Lookup by code point; raises ValueError if unnamed |
11+
| `lookup(name)` | O(1) | O(1) | Lookup by name |
12+
| `category(ch)` | O(1) | O(1) | General category |
13+
| `bidirectional(ch)` | O(1) | O(1) | Bidi class |
14+
| `combining(ch)` | O(1) | O(1) | Canonical combining class |
15+
| `decimal(ch)` / `digit(ch)` / `numeric(ch)` | O(1) | O(1) | Numeric properties |
16+
| `normalize(form, s)` | O(n) | O(n) | n = string length |
17+
| `is_normalized(form, s)` | O(n) | O(1) | Checks normalization |
18+
19+
## Character Properties
20+
21+
```python
22+
import unicodedata
23+
24+
# Basic properties
25+
ch = "é"
26+
print(unicodedata.name(ch)) # LATIN SMALL LETTER E WITH ACUTE
27+
print(unicodedata.category(ch)) # Ll
28+
print(unicodedata.combining(ch)) # 0
29+
print(unicodedata.bidirectional(ch)) # L
30+
31+
# Numeric properties
32+
print(unicodedata.decimal("٢")) # 2
33+
print(unicodedata.digit("")) # 2
34+
print(unicodedata.numeric("")) # 8.0
35+
```
36+
37+
## Name Lookup
38+
39+
```python
40+
import unicodedata
41+
42+
# Lookup by name
43+
ch = unicodedata.lookup("GREEK SMALL LETTER MU") # "μ"
44+
45+
# Safe name lookup with default
46+
name = unicodedata.name("Ω", "UNKNOWN") # "GREEK CAPITAL LETTER OMEGA"
47+
missing = unicodedata.name("😀", None) # Name exists; returns string
48+
```
49+
50+
## Normalization
51+
52+
```python
53+
import unicodedata
54+
55+
text = "cafe\u0301" # "e" + combining acute
56+
57+
# Normalize to NFC/NFD/NFKC/NFKD
58+
nfc = unicodedata.normalize("NFC", text)
59+
nfd = unicodedata.normalize("NFD", text)
60+
61+
print(text == nfc) # False
62+
print(text == nfd) # True
63+
64+
# Check normalization
65+
print(unicodedata.is_normalized("NFC", text)) # False
66+
print(unicodedata.is_normalized("NFD", text)) # True
67+
```
68+
69+
## Related Documentation
70+
71+
- [codecs Module](codecs.md)
72+
- [encodings Module](encodings.md)

docs/stdlib/unittest.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ The `unittest` module provides a framework for unit testing with test cases, fix
1717
import unittest
1818

1919
# Define test class - O(1)
20+
class Calculator:
21+
def add(self, a, b):
22+
return a + b
23+
24+
def subtract(self, a, b):
25+
return a - b
26+
2027
class TestCalculator(unittest.TestCase):
2128

2229
def setUp(self): # O(s) - called before each test
@@ -147,12 +154,6 @@ python -m unittest discover # O(n*t)
147154
python -m unittest -v # O(n*t)
148155
```
149156

150-
## Version Notes
151-
152-
- **Python 2.x**: unittest available (as unittest2 backport)
153-
- **Python 3.x**: Built-in with enhancements
154-
- **Python 3.4+**: Subtests added
155-
156157
## Best Practices
157158

158159
**Do**:

docs/stdlib/urllib.md

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The `urllib` module provides utilities for working with URLs, including fetching
1010
| `urllib.parse.urlencode()` | O(n*m) | O(n*m) | n = items, m = avg value length |
1111
| `urllib.parse.quote()` | O(n) | O(n) | n = string length |
1212
| `urllib.parse.unquote()` | O(n) | O(n) | n = string length |
13-
| `urllib.request.urlopen()` | O(response) | O(response) | Network-bound; response size dominates |
13+
| `urllib.request.urlopen()` | O(response) | O(1) | Network-bound; response size dominates |
1414
| `response.read()` | O(n) | O(n) | n = response size |
1515

1616
## URL Parsing
@@ -114,12 +114,11 @@ from urllib.request import urlopen
114114
try:
115115
with urlopen('https://example.com') as response: # O(network)
116116
content = response.read() # O(n) - n = response size
117+
# Access response metadata - O(1)
118+
status = response.status # 200
119+
headers = response.headers # dict-like
117120
except Exception as e:
118121
print(f"Error: {e}")
119-
120-
# Access response metadata - O(1)
121-
status = response.status # 200
122-
headers = response.headers # dict-like
123122
```
124123

125124
### Reading Response Content
@@ -308,25 +307,6 @@ def fetch_with_retry(url, max_retries=3):
308307
content = fetch_with_retry('https://example.com') # O(response)
309308
```
310309

311-
## Limitations and Alternatives
312-
313-
### When to Use requests Library
314-
315-
```python
316-
# urllib is built-in but basic
317-
# For more features, use requests library (not built-in)
318-
319-
# urllib - basic, manual handling
320-
from urllib.request import urlopen
321-
response = urlopen('https://api.example.com/data')
322-
data = response.read()
323-
324-
# requests - higher-level, more convenient
325-
import requests # Must install: pip install requests
326-
response = requests.get('https://api.example.com/data')
327-
data = response.json() # Auto JSON parsing
328-
```
329-
330310
## Performance Considerations
331311

332312
### Batch Fetching
@@ -378,17 +358,10 @@ content1 = fetch_cached('https://example.com')
378358
content2 = fetch_cached('https://example.com')
379359
```
380360

381-
## Version Notes
382-
383-
- **Python 2.x**: `urllib` and `urllib2` separate modules
384-
- **Python 3.x**: `urllib.request`, `urllib.parse`, `urllib.error` (reorganized)
385-
- **All versions**: Basic functionality stable
386-
387361
## Related Modules
388362

389363
- **[http.client](http.md)** - Lower-level HTTP client
390364
- **[json](json.md)** - Parse JSON responses
391-
- **requests** - Higher-level HTTP library (external)
392365

393366
## Best Practices
394367

docs/stdlib/uuid.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -301,14 +301,9 @@ u = uuid4() # O(1) - cryptographically secure, globally unique
301301
# Random string (worse)
302302
uid = ''.join(random.choices(string.ascii_letters, k=36)) # O(n) - collision possible
303303

304-
# UUID is guaranteed unique across systems and time
304+
# UUIDs are designed to be globally unique, but not absolutely guaranteed
305305
```
306306

307-
## Version Notes
308-
309-
- **Python 3.x**: Full UUID support
310-
- **Python 3.6+**: UUID object improvements
311-
312307
## Related Documentation
313308

314309
- [Random Module](random.md) - Random number generation

docs/stdlib/weakref.md

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Weakref Module
1+
# weakref Module
22

33
The `weakref` module provides utilities for creating weak references to objects, allowing garbage collection when objects are no longer strongly referenced.
44

@@ -115,7 +115,11 @@ class CachedResource:
115115

116116
# Usage
117117
cache = CachedResource()
118-
obj1 = {"data": "value"}
118+
class Data:
119+
def __init__(self, value):
120+
self.value = value
121+
122+
obj1 = Data("value")
119123
cache.register("key1", obj1)
120124

121125
retrieved = cache.get("key1") # O(1)
@@ -235,9 +239,9 @@ class Registry:
235239
# Usage
236240
registry = Registry()
237241

238-
obj1 = {"id": 1}
239-
obj2 = {"id": 2}
240-
obj3 = {"id": 3}
242+
obj1 = Data(1)
243+
obj2 = Data(2)
244+
obj3 = Data(3)
241245

242246
registry.register(obj1) # O(1)
243247
registry.register(obj2) # O(1)
@@ -297,7 +301,7 @@ class TransientCache:
297301

298302
# Usage
299303
cache = TransientCache()
300-
obj = {"data": "value"}
304+
obj = Data("value")
301305
cache._cache["key"] = obj # O(1)
302306

303307
# Query without keeping obj alive
@@ -307,13 +311,7 @@ data = cache.query("key") # O(1)
307311
exists = cache.query_exists("key") # O(1) - won't prevent GC
308312
```
309313

310-
## Version Notes
311-
312-
- **Python 2.6+**: Basic weakref support
313-
- **Python 3.x**: All features available
314-
- **Python 3.13+**: Performance improvements
315-
316314
## Related Documentation
317315

318-
- Gc Module - Garbage collection control
316+
- [gc Module](gc.md) - Garbage collection control
319317
- [Collections Module](collections.md) - OrderedDict alternatives

docs/stdlib/zipapp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ zipapp.create_archive(
2121
'myapp',
2222
target='myapp.pyz',
2323
main='myapp:main',
24-
compression='deflated'
24+
compressed=True
2525
)
2626

2727
# Run:

0 commit comments

Comments
 (0)