# HG changeset patch
# User Nicolas M. Thiery <nthiery@users.sf.net>
# Date 1335967705 -7200
# Node ID bac3fe47020c4854ae21f0526ae96d2e1b757630
# Parent ee1c76488647c6947c8dddc238235e82c6958ed7
[mq]: trac11935_share_on_base_category.patch
diff --git a/sage/categories/bimodules.py b/sage/categories/bimodules.py
a
|
b
|
class Bimodules(CategoryWithParameters): |
49 | 49 | self._left_base_ring = left_base |
50 | 50 | self._right_base_ring = right_base |
51 | 51 | |
| 52 | def _make_named_class_key(self, name): |
| 53 | return (self._left_base_ring.category(), self._right_base_ring.category()) |
| 54 | |
52 | 55 | @classmethod |
53 | 56 | def an_instance(cls): |
54 | 57 | """ |
diff --git a/sage/categories/category.py b/sage/categories/category.py
a
|
b
|
class CategoryWithParameters(Category): |
1786 | 1786 | False |
1787 | 1787 | |
1788 | 1788 | """ |
1789 | | def _make_named_class(self, name, method_provider, cache = "ignore_reduction", **options): |
| 1789 | def _make_named_class(self, name, method_provider, cache = False, **options): |
1790 | 1790 | """ |
1791 | 1791 | Purpose: Create the parent/element/... class of ``self``. |
1792 | 1792 | |
… |
… |
class CategoryWithParameters(Category): |
1852 | 1852 | sage: loads(dumps(PC)) is PC |
1853 | 1853 | True |
1854 | 1854 | """ |
1855 | | # Implementation: we use the cache functionality of |
1856 | | # dynamic_class, and specify that the result depends only on |
1857 | | # the classes this class is built from |
1858 | | # (e.g. ``self.ParentMethods`` and ``c.parent_class`` for each |
1859 | | # super category ``c`` of ``self``) and not on the reduction |
1860 | | # data (which includes ``self``). |
1861 | | return Category._make_named_class(self, name, method_provider, |
1862 | | cache=cache, **options) |
| 1855 | cls = self.__class__ |
| 1856 | key = (cls, name, self._make_named_class_key(name)) |
| 1857 | try: |
| 1858 | return self._make_named_class_cache[key] |
| 1859 | except KeyError: |
| 1860 | pass |
| 1861 | result = Category._make_named_class(self, name, method_provider, |
| 1862 | cache=cache, **options) |
| 1863 | self._make_named_class_cache[key] = result |
| 1864 | return result |
| 1865 | |
| 1866 | |
| 1867 | @abstract_method |
| 1868 | def _make_named_class_key(self, name): |
| 1869 | pass |
| 1870 | |
| 1871 | _make_named_class_cache = dict() |
1863 | 1872 | |
1864 | 1873 | def _subcategory_hook_(self, C): |
1865 | 1874 | """ |
… |
… |
class JoinCategory(CategoryWithParameter |
1948 | 1957 | Category.__init__(self) |
1949 | 1958 | self._super_categories = list(super_categories) |
1950 | 1959 | |
| 1960 | def _make_named_class_key(self, name): |
| 1961 | return tuple(getattr(cat, name) for cat in self._super_categories) |
| 1962 | |
1951 | 1963 | def super_categories(self): |
1952 | 1964 | """ |
1953 | 1965 | Returns the immediate super categories, as per :meth:`Category.super_categories`. |
diff --git a/sage/categories/category_types.py b/sage/categories/category_types.py
a
|
b
|
class Category_over_base(CategoryWithPar |
203 | 203 | Category.__init__(self, name) |
204 | 204 | self.__base = base |
205 | 205 | |
| 206 | def _make_named_class_key(self, name): |
| 207 | return self.__base.category() |
| 208 | |
206 | 209 | @classmethod |
207 | 210 | def an_instance(cls): |
208 | 211 | """ |