On Sunday, September 27, 2015 at 9:01:26 AM UTC-4, Christoph Ortner wrote:
>
> I am writing a Julia wrapper for a molecular simulation library, ASE. As 
> with previous PyCall experiences, this works really well UNTIL I started to 
> benchmark a certain critical portion of the code. For context: I iterate 
> over all atoms and for each atom get the interaction neighbourhood from 
> ASE's neighbourlist.  The call get_neighbours(n) returns bumpy arrays of 
> type Int64.
>

I tried a little benchmark

@pyimport numpy.random as r
a = [pycall(r.rand, PyObject, 10) for i in 1:1000]
@time map(PyArray, a);
@time map(PyCall.PyArray_Info, a);

and it looks like almost all of the conversion time is spent in 
PyArray_Info, which just extracts the information from the 
__array_interface__.   (The problem is that the C NumPy interface for this 
functionality consists entirely of macros, so it is hard to access from 
Julia.)  Hopefully when we get around to switching to the PyBuffer 
interface it will be faster to get this information. 

If it just a bunch of small 1d arrays of integers, you could try to convert 
to PyVector{Int} instead, in case the Python sequence interface is faster.

Reply via email to