arraykit 0.7.2__tar.gz → 0.8.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {arraykit-0.7.2/arraykit.egg-info → arraykit-0.8.1}/PKG-INFO +1 -1
- {arraykit-0.7.2 → arraykit-0.8.1}/README.rst +12 -0
- {arraykit-0.7.2 → arraykit-0.8.1/arraykit.egg-info}/PKG-INFO +1 -1
- {arraykit-0.7.2 → arraykit-0.8.1}/arraykit.egg-info/SOURCES.txt +6 -0
- {arraykit-0.7.2 → arraykit-0.8.1}/setup.py +12 -4
- arraykit-0.8.1/src/_arraykit.c +122 -0
- arraykit-0.8.1/src/array_go.c +264 -0
- arraykit-0.8.1/src/array_to_tuple.c +251 -0
- arraykit-0.8.1/src/block_index.c +1445 -0
- arraykit-0.8.1/src/delimited_to_arrays.c +2972 -0
- arraykit-0.8.1/src/methods.c +1002 -0
- arraykit-0.8.1/src/tri_map.c +1209 -0
- {arraykit-0.7.2 → arraykit-0.8.1}/test/test_util.py +6 -6
- arraykit-0.7.2/src/_arraykit.c +0 -7609
- {arraykit-0.7.2 → arraykit-0.8.1}/LICENSE.txt +0 -0
- {arraykit-0.7.2 → arraykit-0.8.1}/MANIFEST.in +0 -0
- {arraykit-0.7.2 → arraykit-0.8.1}/arraykit.egg-info/dependency_links.txt +0 -0
- {arraykit-0.7.2 → arraykit-0.8.1}/arraykit.egg-info/requires.txt +0 -0
- {arraykit-0.7.2 → arraykit-0.8.1}/arraykit.egg-info/top_level.txt +0 -0
- {arraykit-0.7.2 → arraykit-0.8.1}/setup.cfg +0 -0
- {arraykit-0.7.2 → arraykit-0.8.1}/src/__init__.py +1 -1
- {arraykit-0.7.2 → arraykit-0.8.1}/src/__init__.pyi +0 -0
- {arraykit-0.7.2 → arraykit-0.8.1}/src/py.typed +0 -0
- {arraykit-0.7.2 → arraykit-0.8.1}/test/test_array_go.py +0 -0
- {arraykit-0.7.2 → arraykit-0.8.1}/test/test_block_index.py +0 -0
- {arraykit-0.7.2 → arraykit-0.8.1}/test/test_delimited_to_arrays.py +0 -0
- {arraykit-0.7.2 → arraykit-0.8.1}/test/test_delimited_to_arrays_integration.py +0 -0
- {arraykit-0.7.2 → arraykit-0.8.1}/test/test_delimited_to_arrays_property.py +0 -0
- {arraykit-0.7.2 → arraykit-0.8.1}/test/test_nonzero_1d.py +0 -0
- {arraykit-0.7.2 → arraykit-0.8.1}/test/test_nonzero_1d_property.py +0 -0
- {arraykit-0.7.2 → arraykit-0.8.1}/test/test_pyi.py +0 -0
- {arraykit-0.7.2 → arraykit-0.8.1}/test/test_split_after_count.py +0 -0
- {arraykit-0.7.2 → arraykit-0.8.1}/test/test_tri_map.py +0 -0
- {arraykit-0.7.2 → arraykit-0.8.1}/test/test_type_discovery.py +0 -0
|
@@ -10,7 +10,13 @@ arraykit.egg-info/top_level.txt
|
|
|
10
10
|
src/__init__.py
|
|
11
11
|
src/__init__.pyi
|
|
12
12
|
src/_arraykit.c
|
|
13
|
+
src/array_go.c
|
|
14
|
+
src/array_to_tuple.c
|
|
15
|
+
src/block_index.c
|
|
16
|
+
src/delimited_to_arrays.c
|
|
17
|
+
src/methods.c
|
|
13
18
|
src/py.typed
|
|
19
|
+
src/tri_map.c
|
|
14
20
|
test/test_array_go.py
|
|
15
21
|
test/test_block_index.py
|
|
16
22
|
test/test_delimited_to_arrays.py
|
|
@@ -5,7 +5,7 @@ from setuptools import Extension # type: ignore
|
|
|
5
5
|
from setuptools import setup
|
|
6
6
|
from pathlib import Path
|
|
7
7
|
|
|
8
|
-
AK_VERSION = '0.
|
|
8
|
+
AK_VERSION = '0.8.1'
|
|
9
9
|
|
|
10
10
|
def get_long_description() -> str:
|
|
11
11
|
return '''The ArrayKit library provides utilities for creating and transforming NumPy arrays, implementing performance-critical StaticFrame operations as Python C extensions.
|
|
@@ -32,9 +32,17 @@ def get_ext_dir(*components: tp.Iterable[str]) -> tp.Sequence[str]:
|
|
|
32
32
|
|
|
33
33
|
ak_extension = Extension(
|
|
34
34
|
name='arraykit._arraykit', # build into module
|
|
35
|
-
sources=[
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
sources=[
|
|
36
|
+
'src/_arraykit.c',
|
|
37
|
+
'src/array_go.c',
|
|
38
|
+
'src/array_to_tuple.c',
|
|
39
|
+
'src/block_index.c',
|
|
40
|
+
'src/delimited_to_arrays.c',
|
|
41
|
+
'src/methods.c',
|
|
42
|
+
'src/tri_map.c',
|
|
43
|
+
],
|
|
44
|
+
include_dirs=get_ext_dir('numpy', '_core', 'include') + ['src'],
|
|
45
|
+
library_dirs=get_ext_dir('numpy', '_core', 'lib'),
|
|
38
46
|
define_macros=[("AK_VERSION", AK_VERSION)],
|
|
39
47
|
libraries=['npymath'], # not including mlib at this time
|
|
40
48
|
)
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# include "Python.h"
|
|
2
|
+
|
|
3
|
+
# define PY_ARRAY_UNIQUE_SYMBOL AK_ARRAY_API
|
|
4
|
+
# define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
|
|
5
|
+
|
|
6
|
+
# include "numpy/arrayobject.h"
|
|
7
|
+
|
|
8
|
+
# include "array_go.h"
|
|
9
|
+
# include "array_to_tuple.h"
|
|
10
|
+
# include "block_index.h"
|
|
11
|
+
# include "delimited_to_arrays.h"
|
|
12
|
+
# include "methods.h"
|
|
13
|
+
# include "tri_map.h"
|
|
14
|
+
|
|
15
|
+
static PyMethodDef arraykit_methods[] = {
|
|
16
|
+
{"immutable_filter", immutable_filter, METH_O, NULL},
|
|
17
|
+
{"mloc", mloc, METH_O, NULL},
|
|
18
|
+
{"name_filter", name_filter, METH_O, NULL},
|
|
19
|
+
{"shape_filter", shape_filter, METH_O, NULL},
|
|
20
|
+
{"column_2d_filter", column_2d_filter, METH_O, NULL},
|
|
21
|
+
{"column_1d_filter", column_1d_filter, METH_O, NULL},
|
|
22
|
+
{"row_1d_filter", row_1d_filter, METH_O, NULL},
|
|
23
|
+
{"slice_to_ascending_slice", slice_to_ascending_slice, METH_VARARGS, NULL},
|
|
24
|
+
{"array_deepcopy",
|
|
25
|
+
(PyCFunction)array_deepcopy,
|
|
26
|
+
METH_VARARGS | METH_KEYWORDS,
|
|
27
|
+
NULL},
|
|
28
|
+
{"array_to_tuple_array", array_to_tuple_array, METH_O, NULL},
|
|
29
|
+
{"array_to_tuple_iter", array_to_tuple_iter, METH_O, NULL},
|
|
30
|
+
{"resolve_dtype", resolve_dtype, METH_VARARGS, NULL},
|
|
31
|
+
{"resolve_dtype_iter", resolve_dtype_iter, METH_O, NULL},
|
|
32
|
+
{"first_true_1d",
|
|
33
|
+
(PyCFunction)first_true_1d,
|
|
34
|
+
METH_VARARGS | METH_KEYWORDS,
|
|
35
|
+
NULL},
|
|
36
|
+
{"first_true_2d",
|
|
37
|
+
(PyCFunction)first_true_2d,
|
|
38
|
+
METH_VARARGS | METH_KEYWORDS,
|
|
39
|
+
NULL},
|
|
40
|
+
{"delimited_to_arrays",
|
|
41
|
+
(PyCFunction)delimited_to_arrays,
|
|
42
|
+
METH_VARARGS | METH_KEYWORDS,
|
|
43
|
+
NULL},
|
|
44
|
+
{"iterable_str_to_array_1d",
|
|
45
|
+
(PyCFunction)iterable_str_to_array_1d,
|
|
46
|
+
METH_VARARGS | METH_KEYWORDS,
|
|
47
|
+
NULL},
|
|
48
|
+
{"split_after_count",
|
|
49
|
+
(PyCFunction)split_after_count,
|
|
50
|
+
METH_VARARGS | METH_KEYWORDS,
|
|
51
|
+
NULL},
|
|
52
|
+
{"count_iteration", count_iteration, METH_O, NULL},
|
|
53
|
+
{"nonzero_1d", nonzero_1d, METH_O, NULL},
|
|
54
|
+
{"isna_element",
|
|
55
|
+
(PyCFunction)isna_element,
|
|
56
|
+
METH_VARARGS | METH_KEYWORDS,
|
|
57
|
+
NULL},
|
|
58
|
+
{"dtype_from_element", dtype_from_element, METH_O, NULL},
|
|
59
|
+
{"get_new_indexers_and_screen",
|
|
60
|
+
(PyCFunction)get_new_indexers_and_screen,
|
|
61
|
+
METH_VARARGS | METH_KEYWORDS,
|
|
62
|
+
NULL},
|
|
63
|
+
{NULL},
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
static struct PyModuleDef arraykit_module = {
|
|
67
|
+
PyModuleDef_HEAD_INIT,
|
|
68
|
+
.m_name = "_arraykit",
|
|
69
|
+
.m_doc = NULL,
|
|
70
|
+
.m_size = -1,
|
|
71
|
+
.m_methods = arraykit_methods,
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
PyObject *
|
|
75
|
+
PyInit__arraykit(void)
|
|
76
|
+
{
|
|
77
|
+
import_array();
|
|
78
|
+
|
|
79
|
+
ErrorInitTypeBlocks = PyErr_NewExceptionWithDoc(
|
|
80
|
+
"arraykit.ErrorInitTypeBlocks",
|
|
81
|
+
"RuntimeError error in block initialization.",
|
|
82
|
+
PyExc_RuntimeError,
|
|
83
|
+
NULL);
|
|
84
|
+
if (ErrorInitTypeBlocks == NULL) {
|
|
85
|
+
return NULL;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
PyObject *copy = PyImport_ImportModule("copy");
|
|
89
|
+
if (copy == NULL) {
|
|
90
|
+
return NULL;
|
|
91
|
+
}
|
|
92
|
+
PyObject *deepcopy = PyObject_GetAttrString(copy, "deepcopy");
|
|
93
|
+
Py_DECREF(copy);
|
|
94
|
+
if (deepcopy == NULL) {
|
|
95
|
+
return NULL;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
PyObject *m = PyModule_Create(&arraykit_module);
|
|
99
|
+
if (!m ||
|
|
100
|
+
PyModule_AddStringConstant(m, "__version__", Py_STRINGIFY(AK_VERSION)) ||
|
|
101
|
+
PyType_Ready(&BlockIndexType) ||
|
|
102
|
+
PyType_Ready(&BIIterType) ||
|
|
103
|
+
PyType_Ready(&BIIterSeqType) ||
|
|
104
|
+
PyType_Ready(&BIIterSliceType) ||
|
|
105
|
+
PyType_Ready(&BIIterBoolType) ||
|
|
106
|
+
PyType_Ready(&BIIterContiguousType) ||
|
|
107
|
+
PyType_Ready(&BIIterBlockType) ||
|
|
108
|
+
PyType_Ready(&TriMapType) ||
|
|
109
|
+
PyType_Ready(&ArrayGOType) ||
|
|
110
|
+
PyModule_AddObject(m, "BlockIndex", (PyObject *) &BlockIndexType) ||
|
|
111
|
+
PyModule_AddObject(m, "TriMap", (PyObject *) &TriMapType) ||
|
|
112
|
+
PyModule_AddObject(m, "ArrayGO", (PyObject *) &ArrayGOType) ||
|
|
113
|
+
PyModule_AddObject(m, "deepcopy", deepcopy) ||
|
|
114
|
+
PyModule_AddObject(m, "ErrorInitTypeBlocks", ErrorInitTypeBlocks)
|
|
115
|
+
){
|
|
116
|
+
Py_DECREF(deepcopy);
|
|
117
|
+
Py_XDECREF(m);
|
|
118
|
+
return NULL;
|
|
119
|
+
}
|
|
120
|
+
return m;
|
|
121
|
+
}
|
|
122
|
+
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
# include "Python.h"
|
|
2
|
+
|
|
3
|
+
# define NO_IMPORT_ARRAY
|
|
4
|
+
# define PY_ARRAY_UNIQUE_SYMBOL AK_ARRAY_API
|
|
5
|
+
# define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
|
|
6
|
+
|
|
7
|
+
# include "numpy/arrayobject.h"
|
|
8
|
+
|
|
9
|
+
# include "array_go.h"
|
|
10
|
+
# include "utilities.h"
|
|
11
|
+
|
|
12
|
+
typedef struct ArrayGOObject {
|
|
13
|
+
PyObject_HEAD
|
|
14
|
+
PyObject *array;
|
|
15
|
+
PyObject *list;
|
|
16
|
+
} ArrayGOObject;
|
|
17
|
+
|
|
18
|
+
PyDoc_STRVAR(
|
|
19
|
+
ArrayGO_doc,
|
|
20
|
+
"\n"
|
|
21
|
+
"A grow only, one-dimensional, object type array, "
|
|
22
|
+
"specifically for usage in IndexHierarchy IndexLevel objects.\n"
|
|
23
|
+
"\n"
|
|
24
|
+
"Args:\n"
|
|
25
|
+
" own_iterable: flag iterable as ownable by this instance.\n"
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
PyDoc_STRVAR(
|
|
29
|
+
ArrayGO_copy_doc,
|
|
30
|
+
"Return a new ArrayGO with an immutable array from this ArrayGO\n"
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
PyDoc_STRVAR(ArrayGO_values_doc, "Return the immutable labels array\n");
|
|
34
|
+
|
|
35
|
+
//------------------------------------------------------------------------------
|
|
36
|
+
// ArrayGO utility functions
|
|
37
|
+
|
|
38
|
+
static inline int
|
|
39
|
+
update_array_cache(ArrayGOObject *self)
|
|
40
|
+
{
|
|
41
|
+
if (self->list) {
|
|
42
|
+
if (self->array) {
|
|
43
|
+
PyObject *container = PyTuple_Pack(2, self->array, self->list);
|
|
44
|
+
if (!container) {
|
|
45
|
+
return -1;
|
|
46
|
+
}
|
|
47
|
+
Py_SETREF(self->array, PyArray_Concatenate(container, 0));
|
|
48
|
+
Py_DECREF(container);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
self->array = PyArray_FROM_OT(self->list, NPY_OBJECT);
|
|
52
|
+
}
|
|
53
|
+
PyArray_CLEARFLAGS((PyArrayObject *)self->array, NPY_ARRAY_WRITEABLE);
|
|
54
|
+
Py_CLEAR(self->list);
|
|
55
|
+
}
|
|
56
|
+
return 0;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
//------------------------------------------------------------------------------
|
|
60
|
+
// ArrayGO Methods:
|
|
61
|
+
static char * argnames[] = {"iterable", "own_iterable", NULL};
|
|
62
|
+
|
|
63
|
+
PyObject *
|
|
64
|
+
ArrayGO_new(PyTypeObject *cls, PyObject *args, PyObject *kwargs)
|
|
65
|
+
{
|
|
66
|
+
PyObject *iterable;
|
|
67
|
+
int own_iterable = 0;
|
|
68
|
+
int parsed = PyArg_ParseTupleAndKeywords(
|
|
69
|
+
args, kwargs, "O|$p:ArrayGO", argnames, &iterable, &own_iterable
|
|
70
|
+
);
|
|
71
|
+
if (!parsed) {
|
|
72
|
+
return NULL;
|
|
73
|
+
}
|
|
74
|
+
ArrayGOObject *self = (ArrayGOObject *)cls->tp_alloc(cls, 0);
|
|
75
|
+
if (!self) {
|
|
76
|
+
return NULL;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (PyArray_Check(iterable)) {
|
|
80
|
+
if (!PyDataType_ISOBJECT(PyArray_DESCR((PyArrayObject *)iterable))) {
|
|
81
|
+
PyErr_SetString(PyExc_NotImplementedError,
|
|
82
|
+
"only object arrays are supported");
|
|
83
|
+
Py_DECREF(self);
|
|
84
|
+
return NULL;
|
|
85
|
+
}
|
|
86
|
+
if (own_iterable) {
|
|
87
|
+
// ArrayGO(np.array(...), own_iterable=True)
|
|
88
|
+
PyArray_CLEARFLAGS((PyArrayObject *)iterable, NPY_ARRAY_WRITEABLE);
|
|
89
|
+
self->array = iterable;
|
|
90
|
+
Py_INCREF(iterable);
|
|
91
|
+
return (PyObject *)self;
|
|
92
|
+
}
|
|
93
|
+
// ArrayGO(np.array(...))
|
|
94
|
+
self->array = (PyObject *)AK_immutable_filter((PyArrayObject *)iterable);
|
|
95
|
+
if (!self->array) {
|
|
96
|
+
Py_CLEAR(self);
|
|
97
|
+
}
|
|
98
|
+
return (PyObject *)self;
|
|
99
|
+
}
|
|
100
|
+
if (PyList_CheckExact(iterable) && own_iterable) {
|
|
101
|
+
// ArrayGO([...], own_iterable=True)
|
|
102
|
+
self->list = iterable;
|
|
103
|
+
Py_INCREF(iterable);
|
|
104
|
+
return (PyObject *)self;
|
|
105
|
+
}
|
|
106
|
+
// ArrayGO([...])
|
|
107
|
+
self->list = PySequence_List(iterable);
|
|
108
|
+
if (!self->list) {
|
|
109
|
+
Py_CLEAR(self);
|
|
110
|
+
}
|
|
111
|
+
return (PyObject *)self;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
PyObject *
|
|
115
|
+
ArrayGO_append(ArrayGOObject *self, PyObject *value)
|
|
116
|
+
{
|
|
117
|
+
if (!self->list) {
|
|
118
|
+
self->list = PyList_New(1);
|
|
119
|
+
if (!self->list) {
|
|
120
|
+
return NULL;
|
|
121
|
+
}
|
|
122
|
+
Py_INCREF(value);
|
|
123
|
+
PyList_SET_ITEM(self->list, 0, value);
|
|
124
|
+
}
|
|
125
|
+
else if (PyList_Append(self->list, value)) {
|
|
126
|
+
return NULL;
|
|
127
|
+
}
|
|
128
|
+
Py_RETURN_NONE;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
PyObject *
|
|
132
|
+
ArrayGO_extend(ArrayGOObject *self, PyObject *values)
|
|
133
|
+
{
|
|
134
|
+
if (!self->list) {
|
|
135
|
+
self->list = PySequence_List(values);
|
|
136
|
+
if (!self->list) {
|
|
137
|
+
return NULL;
|
|
138
|
+
}
|
|
139
|
+
Py_RETURN_NONE;
|
|
140
|
+
}
|
|
141
|
+
Py_ssize_t len = PyList_Size(self->list);
|
|
142
|
+
if (len < 0 || PyList_SetSlice(self->list, len, len, values)) {
|
|
143
|
+
return NULL;
|
|
144
|
+
}
|
|
145
|
+
Py_RETURN_NONE;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
PyObject *
|
|
149
|
+
ArrayGO_getnewargs(ArrayGOObject *self, PyObject *Py_UNUSED(unused))
|
|
150
|
+
{
|
|
151
|
+
if (self->list && update_array_cache(self)) {
|
|
152
|
+
return NULL;
|
|
153
|
+
}
|
|
154
|
+
return PyTuple_Pack(1, self->array);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
PyObject *
|
|
158
|
+
ArrayGO_copy(ArrayGOObject *self, PyObject *Py_UNUSED(unused))
|
|
159
|
+
{
|
|
160
|
+
ArrayGOObject *copy = PyObject_GC_New(ArrayGOObject, &ArrayGOType);
|
|
161
|
+
copy->array = self->array;
|
|
162
|
+
copy->list = self->list ? PySequence_List(self->list) : NULL;
|
|
163
|
+
Py_XINCREF(copy->array);
|
|
164
|
+
return (PyObject *)copy;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
PyObject *
|
|
168
|
+
ArrayGO_iter(ArrayGOObject *self)
|
|
169
|
+
{
|
|
170
|
+
if (self->list && update_array_cache(self)) {
|
|
171
|
+
return NULL;
|
|
172
|
+
}
|
|
173
|
+
return PyObject_GetIter(self->array);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
PyObject *
|
|
177
|
+
ArrayGO_mp_subscript(ArrayGOObject *self, PyObject *key)
|
|
178
|
+
{
|
|
179
|
+
if (self->list && update_array_cache(self)) {
|
|
180
|
+
return NULL;
|
|
181
|
+
}
|
|
182
|
+
return PyObject_GetItem(self->array, key);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
Py_ssize_t
|
|
186
|
+
ArrayGO_mp_length(ArrayGOObject *self)
|
|
187
|
+
{
|
|
188
|
+
return ((self->array ? PyArray_SIZE((PyArrayObject *)self->array) : 0)
|
|
189
|
+
+ (self->list ? PyList_Size(self->list) : 0));
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
PyObject *
|
|
193
|
+
ArrayGO_values_getter(ArrayGOObject *self, void* Py_UNUSED(closure))
|
|
194
|
+
{
|
|
195
|
+
if (self->list && update_array_cache(self)) {
|
|
196
|
+
return NULL;
|
|
197
|
+
}
|
|
198
|
+
Py_INCREF(self->array);
|
|
199
|
+
return self->array;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
int
|
|
203
|
+
ArrayGO_traverse(ArrayGOObject *self, visitproc visit, void *arg)
|
|
204
|
+
{
|
|
205
|
+
Py_VISIT(self->array);
|
|
206
|
+
Py_VISIT(self->list);
|
|
207
|
+
return 0;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
int
|
|
211
|
+
ArrayGO_clear(ArrayGOObject *self)
|
|
212
|
+
{
|
|
213
|
+
Py_CLEAR(self->array);
|
|
214
|
+
Py_CLEAR(self->list);
|
|
215
|
+
return 0;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
void
|
|
219
|
+
ArrayGO_dealloc(ArrayGOObject *self)
|
|
220
|
+
{
|
|
221
|
+
Py_XDECREF(self->array);
|
|
222
|
+
Py_XDECREF(self->list);
|
|
223
|
+
Py_TYPE(self)->tp_free((PyObject *)self);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// ArrayGo method bundles
|
|
227
|
+
|
|
228
|
+
static struct PyGetSetDef ArrayGO_getset[] = {
|
|
229
|
+
{"values", (getter)ArrayGO_values_getter, NULL, ArrayGO_values_doc, NULL},
|
|
230
|
+
{NULL},
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
static PyMethodDef ArrayGO_methods[] = {
|
|
234
|
+
{"append", (PyCFunction)ArrayGO_append, METH_O, NULL},
|
|
235
|
+
{"copy", (PyCFunction)ArrayGO_copy, METH_NOARGS, ArrayGO_copy_doc},
|
|
236
|
+
{"extend", (PyCFunction)ArrayGO_extend, METH_O, NULL},
|
|
237
|
+
{"__getnewargs__", (PyCFunction)ArrayGO_getnewargs, METH_NOARGS, NULL},
|
|
238
|
+
{NULL},
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
static PyMappingMethods ArrayGO_as_mapping = {
|
|
242
|
+
.mp_length = (lenfunc)ArrayGO_mp_length,
|
|
243
|
+
.mp_subscript = (binaryfunc) ArrayGO_mp_subscript,
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
//------------------------------------------------------------------------------
|
|
247
|
+
// ArrayGo PyTypeObject
|
|
248
|
+
// https://docs.python.org/3/c-api/typeobj.html
|
|
249
|
+
|
|
250
|
+
PyTypeObject ArrayGOType = {
|
|
251
|
+
PyVarObject_HEAD_INIT(NULL, 0)
|
|
252
|
+
.tp_as_mapping = &ArrayGO_as_mapping,
|
|
253
|
+
.tp_basicsize = sizeof(ArrayGOObject),
|
|
254
|
+
.tp_clear = (inquiry)ArrayGO_clear,
|
|
255
|
+
.tp_dealloc = (destructor)ArrayGO_dealloc,
|
|
256
|
+
.tp_doc = ArrayGO_doc,
|
|
257
|
+
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
|
|
258
|
+
.tp_getset = ArrayGO_getset,
|
|
259
|
+
.tp_iter = (getiterfunc)ArrayGO_iter,
|
|
260
|
+
.tp_methods = ArrayGO_methods,
|
|
261
|
+
.tp_name = "arraykit.ArrayGO",
|
|
262
|
+
.tp_new = ArrayGO_new,
|
|
263
|
+
.tp_traverse = (traverseproc)ArrayGO_traverse,
|
|
264
|
+
};
|