Skip to content

Commit 25ec33b

Browse files
committed
improve code a bit
1 parent ff06499 commit 25ec33b

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

hybrid-programming/example2/example2.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
N = 100_000
77

88
# create points direct buffer and array
9-
points_buffer = jpype.nio.convertToDirectBuffer(bytearray(4 * N * 2)).asFloatBuffer()
9+
points_bytearray = bytearray(4 * N * 2)
10+
points_buffer = jpype.nio.convertToDirectBuffer(points_bytearray).asFloatBuffer()
1011
points = np.asarray(points_buffer).reshape(N, 2)
1112

1213
# create colors direct buffer and array
13-
color_byte_array = bytearray(4 * N)
14-
colors_buffer = jpype.nio.convertToDirectBuffer(color_byte_array).asIntBuffer()
15-
colors = np.asarray(color_byte_array).reshape(N, 4)
14+
color_bytearray = bytearray(4 * N)
15+
colors_buffer = jpype.nio.convertToDirectBuffer(color_bytearray).asIntBuffer()
16+
colors = np.asarray(color_bytearray).reshape(N, 4)
1617

1718
# Note that the `colors_buffer` is like an array of 32 bit Integers, which is
1819
# how Processing stores color values. The `colors` numpy array is an array of

0 commit comments

Comments
 (0)