8000 Clarify that Python integer overflow behavior is undefined · kgryte/array-api@844c6f6 · GitHub
[go: up one dir, main page]

8000 Skip to content

Commit 844c6f6

Browse files
committed
Clarify that Python integer overflow behavior is undefined
1 parent 499564e commit 844c6f6

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

spec/API_specification/type_promotion.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ diagram:
99

1010
![Type promotion diagram](/_static/images/dtype_promotion_lattice.png)
1111

12-
_Type promotion diagram. Promotion between any two types is given by their join on this lattice. Only the types of participating arrays matter, not their values). Dashed lines indicate that behaviour for Python scalars is undefined on overflow. Boolean, integer and floating-point dtypes are not connected, indicating mixed-kind promotion is undefined._
12+
_Type promotion diagram. Promotion between any two types is given by their join on this lattice. Only the types of participating arrays matter, not their values. Dashed lines indicate that behavior for Python scalars is undefined on overflow. Boolean, integer and floating-point dtypes are not connected, indicating mixed-kind promotion is undefined._
1313

1414

1515
## Rules
@@ -106,8 +106,7 @@ where `<op>` is a built-in operator (see {ref}`operators` for operators
106106
supported by the array object) and `scalar` has a compatible type and value
107107
to the array dtype:
108108
- Python `bool` for a `bool` array dtype,
109-
- a positive Python `int` for unsigned integer array dtypes,
110-
- a Python `int` for integer array dtypes,
109+
- a Python `int` within the [bounds](data-types) of the given dtype for integer array dtypes,
111110
- a Python `int` or `float` for floating-point array dtypes
112111
The expected behavior is then equivalent to:
113112

@@ -121,4 +120,7 @@ The expected behavior is then equivalent to:
121120
Behaviour is not specified when mixing a Python `float` and an array with an
122121
integer dtype; this may give `float32`, `float64`, or raise an exception -
123122
behavior of implementations will differ.
123+
124+
The behavior is also not specified for integers outside of the bounds of a
125+
given integer dtype. It may overflow, or result in an error.
124126
```

0 commit comments

Comments
 (0)
0