Skip to content

Commit 3f5cb28

Browse files
committed
Rename GraalPy-speficic PyArray functions
1 parent 9d6508e commit 3f5cb28

File tree

9 files changed

+35
-33
lines changed

9 files changed

+35
-33
lines changed

graalpython/com.oracle.graal.python.cext/include/listobject.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2018, 2024, Oracle and/or its affiliates.
1+
/* Copyright (c) 2018, 2025, Oracle and/or its affiliates.
22
* Copyright (C) 1996-2017 Python Software Foundation
33
*
44
* Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
@@ -46,13 +46,13 @@ PyAPI_FUNC(int) PyList_Reverse(PyObject *);
4646
PyAPI_FUNC(PyObject *) PyList_AsTuple(PyObject *);
4747

4848
/*
49-
* GraalPy-specific, used to implement cython's array.resize_smart
49+
* GraalPy public API, used to implement cython's array.resize_smart
5050
*/
51-
PyAPI_FUNC(int) _PyArray_Resize(PyObject* array, Py_ssize_t new_size);
51+
PyAPI_FUNC(int) GraalPyArray_Resize(PyObject* array, Py_ssize_t new_size);
5252
/*
53-
* GraalPy-specific, used to implement cython's array.data
53+
* GraalPy public API, used to implement cython's array.data
5454
*/
55-
PyAPI_FUNC(char*) _PyArray_Data(PyObject* array);
55+
PyAPI_FUNC(char*) GraalPyArray_Data(PyObject* array);
5656

5757
#ifndef Py_LIMITED_API
5858
# define Py_CPYTHON_LISTOBJECT_H

graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/CApiBuiltinsProcessor.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -751,8 +751,10 @@ private static Path resolvePath(Path path) {
751751
*/
752752
"PySlice_Start", "PySlice_Step", "PySlice_Stop",
753753
"PyObject_GetDoc", "PyObject_SetDoc",
754-
"_PyArray_Resize", "_PyArray_Data",
755-
"_PyErr_Occurred", "_PyNamespace_New", "_Py_GetErrorHandler",
754+
// Only in include/internal/pycore_namespace.h, not public
755+
"_PyNamespace_New",
756+
// Only in include/internal/pycore_fileutils.h, not public
757+
"_Py_GetErrorHandler",
756758
// Not actually additional, only defined on Windows.
757759
// TODO: fix generated CAPIFunctions.txt
758760
"PyUnicode_AsMBCSString", "PyUnicode_EncodeCodePage", "PyUnicode_DecodeMBCS",

graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_array.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved.
22
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
33
#
44
# The Universal Permissive License (UPL), Version 1.0
@@ -62,41 +62,41 @@ def reference_getbuffer(args):
6262
class TestPyArray(CPyExtTestCase):
6363

6464
if sys.implementation.name == 'graalpy':
65-
test__PyArray_Resize = CPyExtFunction(
65+
test_GraalPyArray_Resize = CPyExtFunction(
6666
reference_array_resize,
6767
lambda: (
6868
(array('i', [1, 2, 3]), 1),
6969
(array('i'), 3),
7070
),
7171
code="""
72-
PyObject* wrap__PyArray_Resize(PyObject* array, Py_ssize_t new_size) {
73-
if (_PyArray_Resize(array, new_size) < 0)
72+
PyObject* wrap_GraalPyArray_Resize(PyObject* array, Py_ssize_t new_size) {
73+
if (GraalPyArray_Resize(array, new_size) < 0)
7474
return NULL;
7575
Py_INCREF(array);
7676
return array;
7777
}
7878
""",
79-
callfunction="wrap__PyArray_Resize",
79+
callfunction="wrap_GraalPyArray_Resize",
8080
resultspec="O",
8181
argspec='On',
8282
arguments=["PyObject* array", "Py_ssize_t new_size"],
8383
cmpfunc=unhandled_error_compare,
8484
)
8585

86-
test__PyArray_Data = CPyExtFunction(
86+
test_GraalPyArray_Data = CPyExtFunction(
8787
lambda args: bytes(args[0]),
8888
lambda: (
8989
(TEST_ARRAY, len(TEST_ARRAY) * TEST_ARRAY.itemsize),
9090
),
9191
code="""
92-
PyObject* wrap__PyArray_Data(PyObject* array, Py_ssize_t size) {
93-
char* data = _PyArray_Data(array);
92+
PyObject* wrap_GraalPyArray_Data(PyObject* array, Py_ssize_t size) {
93+
char* data = GraalPyArray_Data(array);
9494
if (data == NULL)
9595
return NULL;
9696
return PyBytes_FromStringAndSize(data, size);
9797
}
9898
""",
99-
callfunction="wrap__PyArray_Data",
99+
callfunction="wrap_GraalPyArray_Data",
100100
resultspec="O",
101101
argspec='On',
102102
arguments=["PyObject* array", "Py_ssize_t size"],

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextArrayBuiltins.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public final class PythonCextArrayBuiltins {
7575
* Graalpy-specific function implemented for Cython
7676
*/
7777
@CApiBuiltin(ret = Int, args = {PyObject, Py_ssize_t}, call = Direct)
78-
abstract static class _PyArray_Resize extends CApiBinaryBuiltinNode {
78+
abstract static class GraalPyArray_Resize extends CApiBinaryBuiltinNode {
7979
@Specialization
8080
static int resize(PArray array, long newSize,
8181
@Bind Node inliningTarget,
@@ -88,7 +88,7 @@ static int resize(PArray array, long newSize,
8888
}
8989

9090
@CApiBuiltin(ret = CHAR_PTR, args = {PyObject}, call = Direct)
91-
abstract static class _PyArray_Data extends CApiUnaryBuiltinNode {
91+
abstract static class GraalPyArray_Data extends CApiUnaryBuiltinNode {
9292
@Specialization
9393
static Object get(PArray array,
9494
@Bind Node inliningTarget,

graalpython/lib-graalpython/patches/Cython-0.29.32.patch

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ index 2c5d709..f6d5cc3 100644
8181
+ getattr(self.type, 'name', None) == '__data_union' and
8282
+ getattr(self.obj.type, 'name') == 'array'
8383
+ ):
84-
+ return self.type.cast_code("_PyArray_Data((PyObject*)%s)" % obj_code)
84+
+ return self.type.cast_code("GraalPyArray_Data((PyObject*)%s)" % obj_code)
8585
return "%s%s%s" % (obj_code, self.op, self.member)
8686

8787
def generate_result_code(self, code):
@@ -408,7 +408,7 @@ index a9e4923..b15a63b 100644
408408
// not designed for filing small increments (but for fast opaque array apps)
409409
static CYTHON_INLINE int resize(arrayobject *self, Py_ssize_t n) {
410410
+#ifdef GRAALVM_PYTHON
411-
+ return _PyArray_Resize((PyObject*)self, n);
411+
+ return GraalPyArray_Resize((PyObject*)self, n);
412412
+#else
413413
void *items = (void*) self->data.ob_item;
414414
PyMem_Resize(items, char, (size_t)(n * self->ob_descr->itemsize));
@@ -423,7 +423,7 @@ index a9e4923..b15a63b 100644
423423
// suitable for small increments; over allocation 50% ;
424424
static CYTHON_INLINE int resize_smart(arrayobject *self, Py_ssize_t n) {
425425
+#ifdef GRAALVM_PYTHON
426-
+ return _PyArray_Resize((PyObject*)self, n);
426+
+ return GraalPyArray_Resize((PyObject*)self, n);
427427
+#else
428428
void *items = (void*) self->data.ob_item;
429429
Py_ssize_t newsize;

graalpython/lib-graalpython/patches/Cython-0.29.37.patch

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ index 305eae9..f5a60ef 100644
8181
+ getattr(self.type, 'name', None) == '__data_union' and
8282
+ getattr(self.obj.type, 'name') == 'array'
8383
+ ):
84-
+ return self.type.cast_code("_PyArray_Data((PyObject*)%s)" % obj_code)
84+
+ return self.type.cast_code("GraalPyArray_Data((PyObject*)%s)" % obj_code)
8585
return "%s%s%s" % (obj_code, self.op, self.member)
8686

8787
def generate_result_code(self, code):
@@ -426,7 +426,7 @@ index a9e4923..b15a63b 100644
426426
// not designed for filing small increments (but for fast opaque array apps)
427427
static CYTHON_INLINE int resize(arrayobject *self, Py_ssize_t n) {
428428
+#ifdef GRAALVM_PYTHON
429-
+ return _PyArray_Resize((PyObject*)self, n);
429+
+ return GraalPyArray_Resize((PyObject*)self, n);
430430
+#else
431431
void *items = (void*) self->data.ob_item;
432432
PyMem_Resize(items, char, (size_t)(n * self->ob_descr->itemsize));
@@ -441,7 +441,7 @@ index a9e4923..b15a63b 100644
441441
// suitable for small increments; over allocation 50% ;
442442
static CYTHON_INLINE int resize_smart(arrayobject *self, Py_ssize_t n) {
443443
+#ifdef GRAALVM_PYTHON
444-
+ return _PyArray_Resize((PyObject*)self, n);
444+
+ return GraalPyArray_Resize((PyObject*)self, n);
445445
+#else
446446
void *items = (void*) self->data.ob_item;
447447
Py_ssize_t newsize;

graalpython/lib-graalpython/patches/Cython-3.0.10.patch

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ index 455d8b6..2d66296 100644
8383
+ getattr(self.type, 'name', None) == '__data_union' and
8484
+ getattr(self.obj.type, 'name') == 'array'
8585
+ ):
86-
+ return self.type.cast_code("_PyArray_Data((PyObject*)%s)" % obj_code)
86+
+ return self.type.cast_code("GraalPyArray_Data((PyObject*)%s)" % obj_code)
8787
return "%s%s%s" % (obj_code, self.op, self.member)
8888

8989
def generate_result_code(self, code):
@@ -363,7 +363,7 @@ index a9e4923..be07e56 100644
363363
// not designed for filing small increments (but for fast opaque array apps)
364364
static CYTHON_INLINE int resize(arrayobject *self, Py_ssize_t n) {
365365
+#ifdef CYTHON_COMPILING_IN_GRAAL
366-
+ return _PyArray_Resize((PyObject*)self, n);
366+
+ return GraalPyArray_Resize((PyObject*)self, n);
367367
+#else
368368
void *items = (void*) self->data.ob_item;
369369
PyMem_Resize(items, char, (size_t)(n * self->ob_descr->itemsize));
@@ -378,7 +378,7 @@ index a9e4923..be07e56 100644
378378
// suitable for small increments; over allocation 50% ;
379379
static CYTHON_INLINE int resize_smart(arrayobject *self, Py_ssize_t n) {
380380
+#ifdef CYTHON_COMPILING_IN_GRAAL
381-
+ return _PyArray_Resize((PyObject*)self, n);
381+
+ return GraalPyArray_Resize((PyObject*)self, n);
382382
+#else
383383
void *items = (void*) self->data.ob_item;
384384
Py_ssize_t newsize;

graalpython/lib-graalpython/patches/catboost-1.2.2.patch

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ index 7b065fca..2c63b85c 100644
198198
+ getattr(self.type, 'name', None) == '__data_union' and
199199
+ getattr(self.obj.type, 'name') == 'array'
200200
+ ):
201-
+ return self.type.cast_code("_PyArray_Data((PyObject*)%s)" % obj_code)
201+
+ return self.type.cast_code("GraalPyArray_Data((PyObject*)%s)" % obj_code)
202202
return "%s%s%s" % (obj_code, self.op, self.member)
203203

204204
def generate_result_code(self, code):
@@ -500,7 +500,7 @@ index a9e49237..b15a63b4 100644
500500
// not designed for filing small increments (but for fast opaque array apps)
501501
static CYTHON_INLINE int resize(arrayobject *self, Py_ssize_t n) {
502502
+#ifdef GRAALVM_PYTHON
503-
+ return _PyArray_Resize((PyObject*)self, n);
503+
+ return GraalPyArray_Resize((PyObject*)self, n);
504504
+#else
505505
void *items = (void*) self->data.ob_item;
506506
PyMem_Resize(items, char, (size_t)(n * self->ob_descr->itemsize));
@@ -515,7 +515,7 @@ index a9e49237..b15a63b4 100644
515515
// suitable for small increments; over allocation 50% ;
516516
static CYTHON_INLINE int resize_smart(arrayobject *self, Py_ssize_t n) {
517517
+#ifdef GRAALVM_PYTHON
518-
+ return _PyArray_Resize((PyObject*)self, n);
518+
+ return GraalPyArray_Resize((PyObject*)self, n);
519519
+#else
520520
void *items = (void*) self->data.ob_item;
521521
Py_ssize_t newsize;

graalpython/lib-graalpython/patches/catboost-1.2.3.patch

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ index 7b065fca..2c63b85c 100644
198198
+ getattr(self.type, 'name', None) == '__data_union' and
199199
+ getattr(self.obj.type, 'name') == 'array'
200200
+ ):
201-
+ return self.type.cast_code("_PyArray_Data((PyObject*)%s)" % obj_code)
201+
+ return self.type.cast_code("GraalPyArray_Data((PyObject*)%s)" % obj_code)
202202
return "%s%s%s" % (obj_code, self.op, self.member)
203203

204204
def generate_result_code(self, code):
@@ -500,7 +500,7 @@ index a9e49237..b15a63b4 100644
500500
// not designed for filing small increments (but for fast opaque array apps)
501501
static CYTHON_INLINE int resize(arrayobject *self, Py_ssize_t n) {
502502
+#ifdef GRAALVM_PYTHON
503-
+ return _PyArray_Resize((PyObject*)self, n);
503+
+ return GraalPyArray_Resize((PyObject*)self, n);
504504
+#else
505505
void *items = (void*) self->data.ob_item;
506506
PyMem_Resize(items, char, (size_t)(n * self->ob_descr->itemsize));
@@ -515,7 +515,7 @@ index a9e49237..b15a63b4 100644
515515
// suitable for small increments; over allocation 50% ;
516516
static CYTHON_INLINE int resize_smart(arrayobject *self, Py_ssize_t n) {
517517
+#ifdef GRAALVM_PYTHON
518-
+ return _PyArray_Resize((PyObject*)self, n);
518+
+ return GraalPyArray_Resize((PyObject*)self, n);
519519
+#else
520520
void *items = (void*) self->data.ob_item;
521521
Py_ssize_t newsize;

0 commit comments

Comments
 (0)