File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 11from  collections import  defaultdict
22
33cimport cython
4+ from  cpython.object cimport PyObject
45from  cpython.pyport cimport PY_SSIZE_T_MAX
56from  cpython.slice cimport PySlice_GetIndicesEx
6- from  cpython.weakref cimport PyWeakref_NewRef
7+ from  cpython.weakref cimport (
8+     PyWeakref_GetObject,
9+     PyWeakref_NewRef,
10+ )
711from  cython cimport Py_ssize_t
812
913import  numpy as  np
@@ -26,6 +30,10 @@ from pandas._libs.util cimport (
2630)
2731
2832
33+ cdef extern from  " Python.h"  :
34+     PyObject*  Py_None
35+ 
36+ 
2937@cython.final 
3038@ cython.freelist (32 )
3139cdef class  BlockPlacement:
@@ -902,7 +910,8 @@ cdef class BlockValuesRefs:
902910        #  see GH#55245 and GH#55008
903911        if  force or  len (self .referenced_blocks) >  self .clear_counter:
904912            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
906915            ]
907916            nr_of_refs =  len (self .referenced_blocks)
908917            if  nr_of_refs <  self .clear_counter //  2 :
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments