# How to Efficiently Index PyArrays?

**URL:** <https://discourse.julialang.org/t/how-to-efficiently-index-pyarrays/69785>\
**Category:** Performance\
**Tags:** question, pycall, python\
**Created:** [October 14, 2021, 10:04pm UTC](https://discourse.julialang.org/t/how-to-efficiently-index-pyarrays/69785 "2021-10-14T22:04:28Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![goerch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerch/32/29122_2.png) [@goerch](https://discourse.julialang.org/u/goerch)\
**Post date:** [October 15, 2021, 10:27pm UTC](https://discourse.julialang.org/t/how-to-efficiently-index-pyarrays/69785/6 "2021-10-15T22:27:28Z")

</div>

Just checked my understanding of the documentation: we pass arrays by reference to python. Modified example from [this thread](https://discourse.julialang.org/t/passing-numpy-arrays-between-python-and-julia/25826/3)

```julia
using PyCall

py"""
import numpy
xs = numpy.zeros((2, 2))
"""

xs = PyArray(py"xs"o)
println(xs)

py"""
import numpy
xs[0, 0] = 1
"""

println(xs)

```

resolves to

```julia
[0.0 0.0; 0.0 0.0]
[1.0 0.0; 0.0 0.0]

```

But of course you are out of luck if Python generates the array.

---

_[View the full topic](https://discourse.julialang.org/t/how-to-efficiently-index-pyarrays/69785)._
