summaryrefslogtreecommitdiff
path: root/gi/pygi-resulttuple.c
diff options
context:
space:
mode:
authorChristoph Reiter <reiter.christoph@gmail.com>2018-03-25 15:29:04 +0200
committerChristoph Reiter <reiter.christoph@gmail.com>2018-03-25 15:33:59 +0200
commit9d6142740c96a2644001430be6d9798041919b09 (patch)
treea3ae704a55d8df1a0d26b05b0a0f2a1ec65f9319 /gi/pygi-resulttuple.c
parent112c9a08577c2e96d1a67ad4619c94368470de74 (diff)
downloadpygobject-9d6142740c96a2644001430be6d9798041919b09.tar.gz
resulttuple: disable the tuple free list under PyPy
This assumes too many cpython internals and pypy complains
Diffstat (limited to 'gi/pygi-resulttuple.c')
-rw-r--r--gi/pygi-resulttuple.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/gi/pygi-resulttuple.c b/gi/pygi-resulttuple.c
index 676595c7..29170176 100644
--- a/gi/pygi-resulttuple.c
+++ b/gi/pygi-resulttuple.c
@@ -24,6 +24,13 @@
static char repr_format_key[] = "__repr_format";
static char tuple_indices_key[] = "__tuple_indices";
+#define PYGI_USE_FREELIST
+
+#ifdef PYPY_VERSION
+#undef PYGI_USE_FREELIST
+#endif
+
+#ifdef PYGI_USE_FREELIST
/* A free list similar to the one used for the CPython tuple. Difference
* is that zero length tuples aren't cached (as we don't need them)
* and that the freelist is smaller as we don't free it with the cyclic GC
@@ -33,6 +40,7 @@ static char tuple_indices_key[] = "__tuple_indices";
#define PyGIResultTuple_MAXFREELIST 100
static PyObject *free_list[PyGIResultTuple_MAXSAVESIZE];
static int numfree[PyGIResultTuple_MAXSAVESIZE];
+#endif
PYGLIB_DEFINE_TYPE ("gi._gi.ResultTuple", PyGIResultTuple_Type, PyTupleObject)
@@ -267,6 +275,7 @@ pygi_resulttuple_new_type(PyObject *tuple_names) {
*/
PyObject *
pygi_resulttuple_new(PyTypeObject *subclass, Py_ssize_t len) {
+#ifdef PYGI_USE_FREELIST
PyObject *self;
Py_ssize_t i;
@@ -288,6 +297,7 @@ pygi_resulttuple_new(PyTypeObject *subclass, Py_ssize_t len) {
return self;
}
}
+#endif
/* For zero length tuples and in case the free list is empty, alloc
* as usual.
@@ -295,6 +305,7 @@ pygi_resulttuple_new(PyTypeObject *subclass, Py_ssize_t len) {
return subclass->tp_alloc (subclass, len);
}
+#ifdef PYGI_USE_FREELIST
static void resulttuple_dealloc(PyObject *self) {
Py_ssize_t i, len;
@@ -323,6 +334,7 @@ static void resulttuple_dealloc(PyObject *self) {
done:
Py_TRASHCAN_SAFE_END (self)
}
+#endif
/**
* pygi_resulttuple_register_types:
@@ -339,7 +351,9 @@ int pygi_resulttuple_register_types(PyObject *module) {
PyGIResultTuple_Type.tp_repr = (reprfunc)resulttuple_repr;
PyGIResultTuple_Type.tp_getattro = (getattrofunc)resulttuple_getattro;
PyGIResultTuple_Type.tp_methods = resulttuple_methods;
+#ifdef PYGI_USE_FREELIST
PyGIResultTuple_Type.tp_dealloc = (destructor)resulttuple_dealloc;
+#endif
if (PyType_Ready (&PyGIResultTuple_Type) < 0)
return -1;