File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -794,9 +794,12 @@ handle_weakrefs(PyGC_Head *unreachable, PyGC_Head *old)
794
794
if (! _PyType_SUPPORTS_WEAKREFS (Py_TYPE (op )))
795
795
continue ;
796
796
797
- /* It supports weakrefs. Does it have any? */
798
- wrlist = (PyWeakReference * * )
799
- _PyObject_GET_WEAKREFS_LISTPTR (op );
797
+ /* It supports weakrefs. Does it have any?
798
+ *
799
+ * This is never triggered for static types so we can avoid the
800
+ * (slightly) more costly _PyObject_GET_WEAKREFS_LISTPTR().
801
+ */
802
+ wrlist = (PyWeakReference * * )_PyObject_GET_BASIC_WEAKREFS_LISTPTR (op );
800
803
801
804
/* `op` may have some weakrefs. March over the list, clear
802
805
* all the weakrefs, and move the weakrefs with callbacks
Original file line number Diff line number Diff line change @@ -1507,7 +1507,10 @@ subtype_dealloc(PyObject *self)
1507
1507
finalizers since they might rely on part of the object
1508
1508
being finalized that has already been destroyed. */
1509
1509
if (type -> tp_weaklistoffset && !base -> tp_weaklistoffset ) {
1510
- /* Modeled after GET_WEAKREFS_LISTPTR() */
1510
+ /* Modeled after GET_WEAKREFS_LISTPTR().
1511
+
1512
+ This is never triggered for static types so we can avoid the
1513
+ (slightly) more costly _PyObject_GET_WEAKREFS_LISTPTR(). */
1511
1514
PyWeakReference * * list = (PyWeakReference * * ) \
1512
1515
_PyObject_GET_BASIC_WEAKREFS_LISTPTR (self );
1513
1516
while (* list )
You can’t perform that action at this time.
0 commit comments