# HG changeset patch
# User Simon King <simon.king@unijena.de>
# Date 1345921193 7200
# Node ID 150be340e81d4f5a68a1701b0ed8b0c7ea1dd422
# Parent 7676500895349a7a7981caa440ff395ebacddcac
imported patch trac_13400_subclass_hook_cython.patch
diff git a/module_list.py b/module_list.py
a

b


151  151  Extension('sage.categories.category_singleton', 
152  152  sources = ['sage/categories/category_singleton.pyx']), 
153  153  
 154  Extension('sage.categories.auxiliary_methods', 
 155  sources = ['sage/categories/auxiliary_methods.pyx']), 
 156  
154  157  Extension('sage.categories.functor', 
155  158  sources = ['sage/categories/functor.pyx']), 
156  159  
diff git a/sage/categories/auxiliary_methods.pyx b/sage/categories/auxiliary_methods.pyx
new file mode 100644


+


 1  include "../ext/python_type.pxi" 
 2  cdef class subcategory_hook: 
 3  cdef object parent_class 
 4  def __init__(self,c): 
 5  self.parent_class = c.parent_class 
 6  def __call__(self,c): 
 7  return PyType_IsSubtype(c.parent_class, self.parent_class) 
diff git a/sage/categories/category.py b/sage/categories/category.py
a

b


106  106  from sage.structure.unique_representation import UniqueRepresentation 
107  107  from sage.structure.dynamic_class import dynamic_class_internal 
108  108  
 109  from sage.categories.auxiliary_methods import subcategory_hook 
 110  
109  111  from weakref import WeakValueDictionary 
110  112  _join_cache = WeakValueDictionary() 
111  113  
… 
… 

619  621  # """ 
620  622  # return hash(self.__category) # Any reason not to use id? 
621  623  
622   def _subcategory_hook_(self, category): 
 624  @lazy_attribute 
 625  def _subcategory_hook_(self):#, category): 
623  626  """ 
624  627  Quick subcategory check. 
625  628  
… 
… 

655  658  sage: Rings()._subcategory_hook_(Rings()) 
656  659  True 
657  660  """ 
658   return issubclass(category.parent_class, self.parent_class) 
 661  return subcategory_hook(self) 
 662  #return issubclass(category.parent_class, self.parent_class) 
659  663  
660  664  def __contains__(self, x): 
661  665  """ 