# Is there a size limit of array in PyCall.array2py?

**URL:** <https://discourse.julialang.org/t/is-there-a-size-limit-of-array-in-pycall-array2py/43072>\
**Category:** New to Julia\
**Tags:** question, package\
**Created:** [July 14, 2020, 6:14pm UTC](https://discourse.julialang.org/t/is-there-a-size-limit-of-array-in-pycall-array2py/43072 "2020-07-14T18:14:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![shriaas2898](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shriaas2898/32/15074_2.png) [@shriaas2898](https://discourse.julialang.org/u/shriaas2898)\
**Post date:** [July 14, 2020, 6:14pm UTC](https://discourse.julialang.org/t/is-there-a-size-limit-of-array-in-pycall-array2py/43072/1 "2020-07-14T18:14:48Z")

</div>

I was trying benchmarking package to test performance of sum using python built-in function. I tried converting array with 10^8 elements to a python list using `PyCall.array2py` and jupyter notebook got hanged I even tried doing the same on my terminal but it also crashed and I had to reboot. So does the Abstract array in `PyCall.array2py` has a limit or it depends on the system? Because I tried creating list with same number of elements in Python and it worked.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [July 14, 2020, 7:40pm UTC](https://discourse.julialang.org/t/is-there-a-size-limit-of-array-in-pycall-array2py/43072/2 "2020-07-14T19:40:56Z")

</div>

No, there shouldn’t be a size limit (other than memory). `10^8` elements work for me:

```julia
julia> @time PyCall.array2py(rand(10^8));
 34.658970 seconds (100.00 M allocations: 2.235 GiB, 26.95% gc time)

```

(I double-checked, and [PyCall calls `PyList_New` and `PyList_SetItem`](https://github.com/JuliaPy/PyCall.jl/blob/064cf66d40ecaf35c336ef0daa89b0029e26e742/src/conversions.jl#L318-L322), which take 64-bit integers … assuming you are using 64-bit Julia and Python.)

---

<div class="post-metadata">

**Author:** ![shriaas2898](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shriaas2898/32/15074_2.png) [@shriaas2898](https://discourse.julialang.org/u/shriaas2898)\
**Post date:** [July 15, 2020, 1:02pm UTC](https://discourse.julialang.org/t/is-there-a-size-limit-of-array-in-pycall-array2py/43072/3 "2020-07-15T13:02:53Z")

</div>

Thanks @stevengj 😃 I guess my poor machine is unable to support the operation​:disappointed:😅. Although it would be good if the function has some timeout limit or show some message while its processing so that it doesn’t looks like it is just stuck there.

---

<div class="post-metadata">

**Author:** ![lungben](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lungben/32/12314_2.png) [@lungben](https://discourse.julialang.org/u/lungben)\
**Post date:** [July 15, 2020, 1:12pm UTC](https://discourse.julialang.org/t/is-there-a-size-limit-of-array-in-pycall-array2py/43072/4 "2020-07-15T13:12:34Z")

</div>

Would it be an option for you to use Numpy arrays on the Python side?  
Transfer of Julia arrays to Numpy arrays is much more efficient than converting them to Python lists.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [July 15, 2020, 4:35pm UTC](https://discourse.julialang.org/t/is-there-a-size-limit-of-array-in-pycall-array2py/43072/5 "2020-07-15T16:35:00Z")

</div>

> [@lungben](#):
>
> Would it be an option for you to use Numpy arrays on the Python side?

I think @shriaas2898 might be trying to follow lecture 1 from [GitHub - mitmath/18S096: 18.S096 three-week course at MIT](https://github.com/mitmath/18S096) , which benchmarks summation in C, Python lists, NumPy arrays, and Julia arrays?

But you don’t need `10^8` items for an accurate benchmark. (I used `10^7` in the notes, which is probably overkill too.)

---

<div class="post-metadata">

**Author:** ![shriaas2898](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shriaas2898/32/15074_2.png) [@shriaas2898](https://discourse.julialang.org/u/shriaas2898)\
**Post date:** [July 15, 2020, 6:36pm UTC](https://discourse.julialang.org/t/is-there-a-size-limit-of-array-in-pycall-array2py/43072/6 "2020-07-15T18:36:05Z")

</div>

Yes @stevengj I was exactly doing that😅  
I have now settled for 10^6 which works fine in all the scenerios. And as @lungben mentioned `numpy` arrays would be better in otherwise scenerios.
