Skip to content

Commit e14440d

Browse files
committed
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.
1 parent 95ff64d commit e14440d

File tree

10 files changed

+20
-110
lines changed

10 files changed

+20
-110
lines changed

psycopg/adapter_asis.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,6 @@ asis_setup(asisObject *self, PyObject *obj)
117117
return 0;
118118
}
119119

120-
static int
121-
asis_traverse(asisObject *self, visitproc visit, void *arg)
122-
{
123-
Py_VISIT(self->wrapped);
124-
return 0;
125-
}
126-
127120
static void
128121
asis_dealloc(PyObject* obj)
129122
{
@@ -187,9 +180,9 @@ PyTypeObject asisType = {
187180
0, /*tp_getattro*/
188181
0, /*tp_setattro*/
189182
0, /*tp_as_buffer*/
190-
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
183+
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /*tp_flags*/
191184
asisType_doc, /*tp_doc*/
192-
(traverseproc)asis_traverse, /*tp_traverse*/
185+
0, /*tp_traverse*/
193186
0, /*tp_clear*/
194187
0, /*tp_richcompare*/
195188
0, /*tp_weaklistoffset*/

psycopg/adapter_binary.c

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -221,17 +221,6 @@ binary_setup(binaryObject *self, PyObject *str)
221221
return 0;
222222
}
223223

224-
static int
225-
binary_traverse(PyObject *obj, visitproc visit, void *arg)
226-
{
227-
binaryObject *self = (binaryObject *)obj;
228-
229-
Py_VISIT(self->wrapped);
230-
Py_VISIT(self->buffer);
231-
Py_VISIT(self->conn);
232-
return 0;
233-
}
234-
235224
static void
236225
binary_dealloc(PyObject* obj)
237226
{
@@ -296,9 +285,9 @@ PyTypeObject binaryType = {
296285
0, /*tp_getattro*/
297286
0, /*tp_setattro*/
298287
0, /*tp_as_buffer*/
299-
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
288+
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /*tp_flags*/
300289
binaryType_doc, /*tp_doc*/
301-
binary_traverse, /*tp_traverse*/
290+
0, /*tp_traverse*/
302291
0, /*tp_clear*/
303292
0, /*tp_richcompare*/
304293
0, /*tp_weaklistoffset*/

psycopg/adapter_datetime.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -183,15 +183,6 @@ pydatetime_setup(pydatetimeObject *self, PyObject *obj, int type)
183183
return 0;
184184
}
185185

186-
static int
187-
pydatetime_traverse(PyObject *obj, visitproc visit, void *arg)
188-
{
189-
pydatetimeObject *self = (pydatetimeObject *)obj;
190-
191-
Py_VISIT(self->wrapped);
192-
return 0;
193-
}
194-
195186
static void
196187
pydatetime_dealloc(PyObject* obj)
197188
{
@@ -254,9 +245,9 @@ PyTypeObject pydatetimeType = {
254245
0, /*tp_getattro*/
255246
0, /*tp_setattro*/
256247
0, /*tp_as_buffer*/
257-
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
248+
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /*tp_flags*/
258249
pydatetimeType_doc, /*tp_doc*/
259-
pydatetime_traverse, /*tp_traverse*/
250+
0, /*tp_traverse*/
260251
0, /*tp_clear*/
261252
0, /*tp_richcompare*/
262253
0, /*tp_weaklistoffset*/

psycopg/adapter_mxdatetime.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -172,15 +172,6 @@ mxdatetime_setup(mxdatetimeObject *self, PyObject *obj, int type)
172172
return 0;
173173
}
174174

175-
static int
176-
mxdatetime_traverse(PyObject *obj, visitproc visit, void *arg)
177-
{
178-
mxdatetimeObject *self = (mxdatetimeObject *)obj;
179-
180-
Py_VISIT(self->wrapped);
181-
return 0;
182-
}
183-
184175
static void
185176
mxdatetime_dealloc(PyObject* obj)
186177
{
@@ -245,9 +236,9 @@ PyTypeObject mxdatetimeType = {
245236
0, /*tp_getattro*/
246237
0, /*tp_setattro*/
247238
0, /*tp_as_buffer*/
248-
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
239+
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /*tp_flags*/
249240
mxdatetimeType_doc, /*tp_doc*/
250-
mxdatetime_traverse, /*tp_traverse*/
241+
0, /*tp_traverse*/
251242
0, /*tp_clear*/
252243
0, /*tp_richcompare*/
253244
0, /*tp_weaklistoffset*/

psycopg/adapter_pboolean.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,6 @@ pboolean_setup(pbooleanObject *self, PyObject *obj)
114114
return 0;
115115
}
116116

117-
static int
118-
pboolean_traverse(PyObject *obj, visitproc visit, void *arg)
119-
{
120-
pbooleanObject *self = (pbooleanObject *)obj;
121-
122-
Py_VISIT(self->wrapped);
123-
return 0;
124-
}
125-
126117
static void
127118
pboolean_dealloc(PyObject* obj)
128119
{
@@ -187,9 +178,9 @@ PyTypeObject pbooleanType = {
187178
0, /*tp_getattro*/
188179
0, /*tp_setattro*/
189180
0, /*tp_as_buffer*/
190-
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
181+
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /*tp_flags*/
191182
pbooleanType_doc, /*tp_doc*/
192-
pboolean_traverse, /*tp_traverse*/
183+
0, /*tp_traverse*/
193184
0, /*tp_clear*/
194185
0, /*tp_richcompare*/
195186
0, /*tp_weaklistoffset*/

psycopg/adapter_pdecimal.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,6 @@ pdecimal_setup(pdecimalObject *self, PyObject *obj)
170170
return 0;
171171
}
172172

173-
static int
174-
pdecimal_traverse(PyObject *obj, visitproc visit, void *arg)
175-
{
176-
pdecimalObject *self = (pdecimalObject *)obj;
177-
178-
Py_VISIT(self->wrapped);
179-
return 0;
180-
}
181-
182173
static void
183174
pdecimal_dealloc(PyObject* obj)
184175
{
@@ -243,9 +234,9 @@ PyTypeObject pdecimalType = {
243234
0, /*tp_getattro*/
244235
0, /*tp_setattro*/
245236
0, /*tp_as_buffer*/
246-
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
237+
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /*tp_flags*/
247238
pdecimalType_doc, /*tp_doc*/
248-
pdecimal_traverse, /*tp_traverse*/
239+
0, /*tp_traverse*/
249240
0, /*tp_clear*/
250241
0, /*tp_richcompare*/
251242
0, /*tp_weaklistoffset*/

psycopg/adapter_pfloat.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,6 @@ pfloat_setup(pfloatObject *self, PyObject *obj)
143143
return 0;
144144
}
145145

146-
static int
147-
pfloat_traverse(PyObject *obj, visitproc visit, void *arg)
148-
{
149-
pfloatObject *self = (pfloatObject *)obj;
150-
151-
Py_VISIT(self->wrapped);
152-
return 0;
153-
}
154-
155146
static void
156147
pfloat_dealloc(PyObject* obj)
157148
{
@@ -216,9 +207,9 @@ PyTypeObject pfloatType = {
216207
0, /*tp_getattro*/
217208
0, /*tp_setattro*/
218209
0, /*tp_as_buffer*/
219-
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
210+
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /*tp_flags*/
220211
pfloatType_doc, /*tp_doc*/
221-
pfloat_traverse, /*tp_traverse*/
212+
0, /*tp_traverse*/
222213
0, /*tp_clear*/
223214
0, /*tp_richcompare*/
224215
0, /*tp_weaklistoffset*/

psycopg/adapter_pint.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,6 @@ pint_setup(pintObject *self, PyObject *obj)
129129
return 0;
130130
}
131131

132-
static int
133-
pint_traverse(PyObject *obj, visitproc visit, void *arg)
134-
{
135-
pintObject *self = (pintObject *)obj;
136-
137-
Py_VISIT(self->wrapped);
138-
return 0;
139-
}
140-
141132
static void
142133
pint_dealloc(PyObject* obj)
143134
{
@@ -202,9 +193,9 @@ PyTypeObject pintType = {
202193
0, /*tp_getattro*/
203194
0, /*tp_setattro*/
204195
0, /*tp_as_buffer*/
205-
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
196+
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /*tp_flags*/
206197
pintType_doc, /*tp_doc*/
207-
pint_traverse, /*tp_traverse*/
198+
0, /*tp_traverse*/
208199
0, /*tp_clear*/
209200
0, /*tp_richcompare*/
210201
0, /*tp_weaklistoffset*/

psycopg/adapter_qstring.c

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -209,17 +209,6 @@ qstring_setup(qstringObject *self, PyObject *str)
209209
return 0;
210210
}
211211

212-
static int
213-
qstring_traverse(PyObject *obj, visitproc visit, void *arg)
214-
{
215-
qstringObject *self = (qstringObject *)obj;
216-
217-
Py_VISIT(self->wrapped);
218-
Py_VISIT(self->buffer);
219-
Py_VISIT(self->conn);
220-
return 0;
221-
}
222-
223212
static void
224213
qstring_dealloc(PyObject* obj)
225214
{
@@ -285,9 +274,9 @@ PyTypeObject qstringType = {
285274
0, /*tp_getattro*/
286275
0, /*tp_setattro*/
287276
0, /*tp_as_buffer*/
288-
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
277+
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /*tp_flags*/
289278
qstringType_doc, /*tp_doc*/
290-
qstring_traverse, /*tp_traverse*/
279+
0, /*tp_traverse*/
291280
0, /*tp_clear*/
292281
0, /*tp_richcompare*/
293282
0, /*tp_weaklistoffset*/

psycopg/diagnostics_type.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,6 @@ diagnostics_init(diagnosticsObject *self, PyObject *args, PyObject *kwds)
133133
return 0;
134134
}
135135

136-
static int
137-
diagnostics_traverse(diagnosticsObject *self, visitproc visit, void *arg)
138-
{
139-
Py_VISIT(self->err);
140-
return 0;
141-
}
142-
143136
static void
144137
diagnostics_dealloc(diagnosticsObject* self)
145138
{
@@ -183,9 +176,9 @@ PyTypeObject diagnosticsType = {
183176
0, /*tp_getattro*/
184177
0, /*tp_setattro*/
185178
0, /*tp_as_buffer*/
186-
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
179+
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /*tp_flags*/
187180
diagnosticsType_doc, /*tp_doc*/
188-
(traverseproc)diagnostics_traverse, /*tp_traverse*/
181+
0, /*tp_traverse*/
189182
0, /*tp_clear*/
190183
0, /*tp_richcompare*/
191184
0, /*tp_weaklistoffset*/

0 commit comments

Comments
 (0)