File tree 1 file changed +11
-2
lines changed
1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 1
1
from collections import defaultdict
2
2
3
3
cimport cython
4
+ from cpython.object cimport PyObject
4
5
from cpython.pyport cimport PY_SSIZE_T_MAX
5
6
from cpython.slice cimport PySlice_GetIndicesEx
6
- from cpython.weakref cimport PyWeakref_NewRef
7
+ from cpython.weakref cimport (
8
+ PyWeakref_GetObject,
9
+ PyWeakref_NewRef,
10
+ )
7
11
from cython cimport Py_ssize_t
8
12
9
13
import numpy as np
@@ -26,6 +30,10 @@ from pandas._libs.util cimport (
26
30
)
27
31
28
32
33
+ cdef extern from " Python.h" :
34
+ PyObject* Py_None
35
+
36
+
29
37
@cython.final
30
38
@ cython.freelist (32 )
31
39
cdef class BlockPlacement:
@@ -902,7 +910,8 @@ cdef class BlockValuesRefs:
902
910
# see GH#55245 and GH#55008
903
911
if force or len (self .referenced_blocks) > self .clear_counter:
904
912
self .referenced_blocks = [
905
- ref for ref in self .referenced_blocks if ref() is not None
913
+ ref for ref in self .referenced_blocks
914
+ if PyWeakref_GetObject(ref) != Py_None
906
915
]
907
916
nr_of_refs = len (self .referenced_blocks)
908
917
if nr_of_refs < self .clear_counter // 2 :
You can’t perform that action at this time.
0 commit comments