Skip to content

Commit 0963780

Browse files
committed
PArray: do not use the GIL for getBufferLength
1 parent 3b9e75b commit 0963780

File tree

1 file changed

+5
-10
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array

1 file changed

+5
-10
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/PArray.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
// TODO interop library
4848
@ExportLibrary(PythonObjectLibrary.class)
4949
public final class PArray extends PythonBuiltinObject {
50-
private BufferFormat format;
51-
private String formatStr;
50+
private final BufferFormat format;
51+
private final String formatStr;
5252
private int length;
5353
private byte[] buffer;
5454
private volatile int exports;
@@ -177,20 +177,15 @@ static boolean isBuffer(@SuppressWarnings("unused") PArray self) {
177177
byte[] getBufferBytes(@Exclusive @Cached GilNode gil) {
178178
boolean mustRelease = gil.acquire();
179179
try {
180-
return PythonUtils.arrayCopyOf(buffer, getBufferLength(gil));
180+
return PythonUtils.arrayCopyOf(buffer, getBufferLength());
181181
} finally {
182182
gil.release(mustRelease);
183183
}
184184
}
185185

186186
@ExportMessage
187-
int getBufferLength(@Exclusive @Cached GilNode gil) {
188-
boolean mustRelease = gil.acquire();
189-
try {
190-
return length * format.bytesize;
191-
} finally {
192-
gil.release(mustRelease);
193-
}
187+
int getBufferLength() {
188+
return length * format.bytesize;
194189
}
195190

196191
public enum MachineFormat {

0 commit comments

Comments
 (0)