originell/jpype — pull request #74 by marscher (2014-07-15 17:59:16+00:00)
Title: Set array range (slices) via (optional) underlying buffer of input sequence 

This PR uses underlying buffer protocol (used by builtin array type and numpy for instance) to directly set the memory in the corresponding JNI array setter call.

This improves the speed and memory usage drastically:

n = 10**7
data = np.random.random(n)
data_list = map(float, range(n))
a = jpype.JArray(jpype.JDouble, 1)(n)

%timeit a[:] = data_list
1 loops, best of 3: 273 ms per loop
%timeit a[:] = data
10 loops, best of 3: 27 ms per loop

Factor of ten :+1: (Memory usage is also in this order of magnitude, since the non numpy version creates one Python object for every element. ~76 Mb vs 650 mb (np vs. py))

Hopefully someone can also test this. So far I did not found any memoryleaks.
Best, Martin