Skip to content

Commit 27a96be

Browse files
Docs: Add complex methods and attributes tables
Add formal tables for conjugate, from_number methods and real, imag attributes with complexity information. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 024f753 commit 27a96be

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

docs/builtins/complex_func.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,21 @@ sqrt_c = cmath.sqrt(c) # O(1)
335335
exp_c = cmath.exp(c) # O(1)
336336
```
337337

338-
## Attributes and Methods
338+
## Methods
339+
340+
| Method | Time | Space | Notes |
341+
|--------|------|-------|-------|
342+
| `conjugate()` | O(1) | O(1) | Return complex conjugate (flip sign of imaginary) |
343+
| `from_number(x)` | O(1) | O(1) | Class method; convert number to complex (Python 3.14+) |
344+
345+
## Attributes
346+
347+
| Attribute | Time | Notes |
348+
|-----------|------|-------|
349+
| `real` | O(1) | Real part as float |
350+
| `imag` | O(1) | Imaginary part as float |
351+
352+
## Attributes and Methods Examples
339353

340354
```python
341355
# O(1) - access properties
@@ -351,6 +365,9 @@ magnitude = abs(c) # 5.0
351365
# Phase angle
352366
import cmath
353367
phase = cmath.phase(c) # atan2(4, 3)
368+
369+
# From number (Python 3.14+)
370+
c = complex.from_number(3.14) # (3.14+0j)
354371
```
355372

356373
## Best Practices

0 commit comments

Comments
 (0)