From e14440d96d5aa70285e77bb26b979ea0dad84d6d Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Fri, 5 Apr 2013 01:02:47 +0100 Subject: [PATCH] Dropped GC support for several objects Non-containers don't need GC. It was half-baked anyway as the tp_clear was often not set. Dropped tp_traverse too for these objects as unused. --- psycopg/adapter_asis.c | 11 ++--------- psycopg/adapter_binary.c | 15 ++------------- psycopg/adapter_datetime.c | 13 ++----------- psycopg/adapter_mxdatetime.c | 13 ++----------- psycopg/adapter_pboolean.c | 13 ++----------- psycopg/adapter_pdecimal.c | 13 ++----------- psycopg/adapter_pfloat.c | 13 ++----------- psycopg/adapter_pint.c | 13 ++----------- psycopg/adapter_qstring.c | 15 ++------------- psycopg/diagnostics_type.c | 11 ++--------- 10 files changed, 20 insertions(+), 110 deletions(-) diff --git a/psycopg/adapter_asis.c b/psycopg/adapter_asis.c index 7f5d3850..a2a8f4dc 100644 --- a/psycopg/adapter_asis.c +++ b/psycopg/adapter_asis.c @@ -117,13 +117,6 @@ asis_setup(asisObject *self, PyObject *obj) return 0; } -static int -asis_traverse(asisObject *self, visitproc visit, void *arg) -{ - Py_VISIT(self->wrapped); - return 0; -} - static void asis_dealloc(PyObject* obj) { @@ -187,9 +180,9 @@ PyTypeObject asisType = { 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /*tp_flags*/ asisType_doc, /*tp_doc*/ - (traverseproc)asis_traverse, /*tp_traverse*/ + 0, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ diff --git a/psycopg/adapter_binary.c b/psycopg/adapter_binary.c index 08f41b84..54f0f656 100644 --- a/psycopg/adapter_binary.c +++ b/psycopg/adapter_binary.c @@ -221,17 +221,6 @@ binary_setup(binaryObject *self, PyObject *str) return 0; } -static int -binary_traverse(PyObject *obj, visitproc visit, void *arg) -{ - binaryObject *self = (binaryObject *)obj; - - Py_VISIT(self->wrapped); - Py_VISIT(self->buffer); - Py_VISIT(self->conn); - return 0; -} - static void binary_dealloc(PyObject* obj) { @@ -296,9 +285,9 @@ PyTypeObject binaryType = { 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /*tp_flags*/ binaryType_doc, /*tp_doc*/ - binary_traverse, /*tp_traverse*/ + 0, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ diff --git a/psycopg/adapter_datetime.c b/psycopg/adapter_datetime.c index 9713a5a5..67697fba 100644 --- a/psycopg/adapter_datetime.c +++ b/psycopg/adapter_datetime.c @@ -183,15 +183,6 @@ pydatetime_setup(pydatetimeObject *self, PyObject *obj, int type) return 0; } -static int -pydatetime_traverse(PyObject *obj, visitproc visit, void *arg) -{ - pydatetimeObject *self = (pydatetimeObject *)obj; - - Py_VISIT(self->wrapped); - return 0; -} - static void pydatetime_dealloc(PyObject* obj) { @@ -254,9 +245,9 @@ PyTypeObject pydatetimeType = { 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /*tp_flags*/ pydatetimeType_doc, /*tp_doc*/ - pydatetime_traverse, /*tp_traverse*/ + 0, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ diff --git a/psycopg/adapter_mxdatetime.c b/psycopg/adapter_mxdatetime.c index 470f12fc..4696a9d0 100644 --- a/psycopg/adapter_mxdatetime.c +++ b/psycopg/adapter_mxdatetime.c @@ -172,15 +172,6 @@ mxdatetime_setup(mxdatetimeObject *self, PyObject *obj, int type) return 0; } -static int -mxdatetime_traverse(PyObject *obj, visitproc visit, void *arg) -{ - mxdatetimeObject *self = (mxdatetimeObject *)obj; - - Py_VISIT(self->wrapped); - return 0; -} - static void mxdatetime_dealloc(PyObject* obj) { @@ -245,9 +236,9 @@ PyTypeObject mxdatetimeType = { 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /*tp_flags*/ mxdatetimeType_doc, /*tp_doc*/ - mxdatetime_traverse, /*tp_traverse*/ + 0, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ diff --git a/psycopg/adapter_pboolean.c b/psycopg/adapter_pboolean.c index 879e233d..f8cd9959 100644 --- a/psycopg/adapter_pboolean.c +++ b/psycopg/adapter_pboolean.c @@ -114,15 +114,6 @@ pboolean_setup(pbooleanObject *self, PyObject *obj) return 0; } -static int -pboolean_traverse(PyObject *obj, visitproc visit, void *arg) -{ - pbooleanObject *self = (pbooleanObject *)obj; - - Py_VISIT(self->wrapped); - return 0; -} - static void pboolean_dealloc(PyObject* obj) { @@ -187,9 +178,9 @@ PyTypeObject pbooleanType = { 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /*tp_flags*/ pbooleanType_doc, /*tp_doc*/ - pboolean_traverse, /*tp_traverse*/ + 0, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ diff --git a/psycopg/adapter_pdecimal.c b/psycopg/adapter_pdecimal.c index 09748514..35721417 100644 --- a/psycopg/adapter_pdecimal.c +++ b/psycopg/adapter_pdecimal.c @@ -170,15 +170,6 @@ pdecimal_setup(pdecimalObject *self, PyObject *obj) return 0; } -static int -pdecimal_traverse(PyObject *obj, visitproc visit, void *arg) -{ - pdecimalObject *self = (pdecimalObject *)obj; - - Py_VISIT(self->wrapped); - return 0; -} - static void pdecimal_dealloc(PyObject* obj) { @@ -243,9 +234,9 @@ PyTypeObject pdecimalType = { 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /*tp_flags*/ pdecimalType_doc, /*tp_doc*/ - pdecimal_traverse, /*tp_traverse*/ + 0, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ diff --git a/psycopg/adapter_pfloat.c b/psycopg/adapter_pfloat.c index abdc8a4c..7bb7a467 100644 --- a/psycopg/adapter_pfloat.c +++ b/psycopg/adapter_pfloat.c @@ -143,15 +143,6 @@ pfloat_setup(pfloatObject *self, PyObject *obj) return 0; } -static int -pfloat_traverse(PyObject *obj, visitproc visit, void *arg) -{ - pfloatObject *self = (pfloatObject *)obj; - - Py_VISIT(self->wrapped); - return 0; -} - static void pfloat_dealloc(PyObject* obj) { @@ -216,9 +207,9 @@ PyTypeObject pfloatType = { 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /*tp_flags*/ pfloatType_doc, /*tp_doc*/ - pfloat_traverse, /*tp_traverse*/ + 0, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ diff --git a/psycopg/adapter_pint.c b/psycopg/adapter_pint.c index ece7a9ca..6465acec 100644 --- a/psycopg/adapter_pint.c +++ b/psycopg/adapter_pint.c @@ -129,15 +129,6 @@ pint_setup(pintObject *self, PyObject *obj) return 0; } -static int -pint_traverse(PyObject *obj, visitproc visit, void *arg) -{ - pintObject *self = (pintObject *)obj; - - Py_VISIT(self->wrapped); - return 0; -} - static void pint_dealloc(PyObject* obj) { @@ -202,9 +193,9 @@ PyTypeObject pintType = { 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /*tp_flags*/ pintType_doc, /*tp_doc*/ - pint_traverse, /*tp_traverse*/ + 0, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ diff --git a/psycopg/adapter_qstring.c b/psycopg/adapter_qstring.c index 0d7fd6fe..6728017e 100644 --- a/psycopg/adapter_qstring.c +++ b/psycopg/adapter_qstring.c @@ -209,17 +209,6 @@ qstring_setup(qstringObject *self, PyObject *str) return 0; } -static int -qstring_traverse(PyObject *obj, visitproc visit, void *arg) -{ - qstringObject *self = (qstringObject *)obj; - - Py_VISIT(self->wrapped); - Py_VISIT(self->buffer); - Py_VISIT(self->conn); - return 0; -} - static void qstring_dealloc(PyObject* obj) { @@ -285,9 +274,9 @@ PyTypeObject qstringType = { 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /*tp_flags*/ qstringType_doc, /*tp_doc*/ - qstring_traverse, /*tp_traverse*/ + 0, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ diff --git a/psycopg/diagnostics_type.c b/psycopg/diagnostics_type.c index 77019bfb..c9f8a57a 100644 --- a/psycopg/diagnostics_type.c +++ b/psycopg/diagnostics_type.c @@ -133,13 +133,6 @@ diagnostics_init(diagnosticsObject *self, PyObject *args, PyObject *kwds) return 0; } -static int -diagnostics_traverse(diagnosticsObject *self, visitproc visit, void *arg) -{ - Py_VISIT(self->err); - return 0; -} - static void diagnostics_dealloc(diagnosticsObject* self) { @@ -183,9 +176,9 @@ PyTypeObject diagnosticsType = { 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /*tp_flags*/ diagnosticsType_doc, /*tp_doc*/ - (traverseproc)diagnostics_traverse, /*tp_traverse*/ + 0, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/