Skip to content

Commit 522c42a

Browse files
committed
Fix big integer documentation to match actual behavior
Integers larger than 64 bits are returned as strings, not integers.
1 parent cf321a6 commit 522c42a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

docs/type-conversion.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Return values from Python are converted back to Erlang:
6262

6363
| Python | Erlang | Notes |
6464
|--------|--------|-------|
65-
| `int` | `integer()` | Arbitrary precision supported |
65+
| `int` | `integer()` or `string()` | Integers > 64 bits returned as strings |
6666
| `float` | `float()` | IEEE 754 double precision |
6767
| `float('nan')` | `nan` | Atom for Not-a-Number |
6868
| `float('inf')` | `infinity` | Atom for positive infinity |
@@ -83,7 +83,9 @@ Return values from Python are converted back to Erlang:
8383
```erlang
8484
%% Integers
8585
{ok, 42} = py:eval(<<"42">>).
86-
{ok, 123456789012345678901234567890} = py:eval(<<"123456789012345678901234567890">>).
86+
87+
%% Big integers (> 64 bits) are returned as strings
88+
{ok, "123456789012345678901234567890"} = py:eval(<<"123456789012345678901234567890">>).
8789

8890
%% Floats
8991
{ok, 3.14} = py:eval(<<"3.14">>).
@@ -248,7 +250,7 @@ Some Python types cannot be directly converted:
248250

249251
- **Large strings**: Binary conversion is efficient, but very large strings may cause memory pressure
250252
- **Deep nesting**: Deeply nested structures require recursive traversal
251-
- **Big integers**: Arbitrary precision integers work but large ones are slower
253+
- **Big integers**: Integers larger than 64 bits are returned as strings; convert with `list_to_integer/1` if needed
252254
- **NumPy arrays**: Call `.tolist()` for explicit conversion; direct array conversion may be slower
253255

254256
For large data transfers, consider:

0 commit comments

Comments
 (0)