File tree Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Original file line number Diff line number Diff line change @@ -12,14 +12,13 @@ This simple example illustrates that:
12
12
13
13
``` python
14
14
x = ones(1 )
15
- x += 2
16
- y = x # `y` *may* be a view
15
+ y = x[:] # `y` *may* be a view on the data of `x`
17
16
y -= 1 # if `y` is a view, this modifies `x`
18
17
```
19
18
20
19
Code as simple as the above example will not be portable between array
21
- libraries - for NumPy/PyTorch/CuPy/MXNet ` x ` will contain the value ` 2 ` ,
22
- while for TensorFlow/JAX/Dask it will contain the value ` 3 ` . The combination
20
+ libraries - for NumPy/PyTorch/CuPy/MXNet ` x ` will contain the value ` 0 ` ,
21
+ while for TensorFlow/JAX/Dask it will contain the value ` 1 ` . The combination
23
22
of views and mutability is fundamentally problematic here if the goal is to
24
23
be able to write code with unambiguous semantics.
25
24
You can’t perform that action at this time.
0 commit comments