@@ -27,9 +27,40 @@ InstallTrueMethod( IsPreAbelianCategory, IsAbelianCategory );
27
27
28
28
# #
29
29
InstallValue( CAP_INTERNAL,
30
- rec (
31
- name_counter := 0 ,
32
- default_cache_type := " weak" ,
30
+ rec (
31
+ name_counter := 0 ,
32
+ default_cache_type := " weak" ,
33
+ operation_names_with_cache_disabled_by_default := [
34
+ # the following operations are needed for comparison in caches
35
+ " IsEqualForObjects" ,
36
+ " IsEqualForMorphisms" ,
37
+ " IsEqualForMorphismsOnMor" ,
38
+ " IsEqualForCacheForObjects" ,
39
+ " IsEqualForCacheForMorphisms" ,
40
+ # it is unclear how `IsEqualForCacheForObjects` and `IsEqualForCacheForMorphisms`
41
+ # would behave on non-well-defined objects/morphisms, so exclude `IsWellDefined*`
42
+ " IsWellDefinedForObjects" ,
43
+ " IsWellDefinedForMorphisms" ,
44
+ " IsWellDefinedForTwoCells" ,
45
+ # do not cache operations returning random data
46
+ " RandomObjectByInteger" ,
47
+ " RandomMorphismByInteger" ,
48
+ " RandomMorphismWithFixedSourceByInteger" ,
49
+ " RandomMorphismWithFixedRangeByInteger" ,
50
+ " RandomMorphismWithFixedSourceAndRangeByInteger" ,
51
+ " RandomObjectByList" ,
52
+ " RandomMorphismByList" ,
53
+ " RandomMorphismWithFixedSourceByList" ,
54
+ " RandomMorphismWithFixedRangeByList" ,
55
+ " RandomMorphismWithFixedSourceAndRangeByList" ,
56
+ # by default, do not cache constructors and object/morphism data
57
+ # because in general these operations are cheap,
58
+ # so caching would not improve the performance
59
+ " ObjectConstructor" ,
60
+ " ObjectDatum" ,
61
+ " MorphismConstructor" ,
62
+ " MorphismDatum" ,
63
+ ] ,
33
64
)
34
65
);
35
66
@@ -80,7 +111,7 @@ InstallGlobalFunction( GET_METHOD_CACHE,
80
111
cache := CreateWeakCachingObject( number );
81
112
elif cache_type = " crisp" then
82
113
cache := CreateCrispCachingObject( number );
83
- elif cache_type = " none" or cache_type = " never " then
114
+ elif cache_type = " none" then
84
115
cache := CreateCrispCachingObject( number );
85
116
DeactivateCachingObject( cache );
86
117
else
@@ -184,7 +215,7 @@ end );
184
215
InstallGlobalFunction( " CREATE_CAP_CATEGORY_OBJECT" ,
185
216
186
217
function ( obj_rec, attr_list )
187
- local i, flatted_attribute_list, obj;
218
+ local i, flatted_attribute_list, obj, operation_name ;
188
219
189
220
for i in [ 1 .. Length( attr_list ) ] do
190
221
@@ -215,30 +246,13 @@ InstallGlobalFunction( "CREATE_CAP_CATEGORY_OBJECT",
215
246
216
247
obj!. derivations_weight_list := MakeOperationWeightList( obj, CAP_INTERNAL_DERIVATION_GRAPH );
217
248
218
- obj!. caches := rec ( IsEqualForObjects := " never" ,
219
- IsEqualForMorphisms := " never" ,
220
- IsEqualForMorphismsOnMor := " never" ,
221
- IsEqualForCacheForObjects := " never" ,
222
- IsEqualForCacheForMorphisms := " never" ,
223
- IsWellDefinedForObjects := " never" ,
224
- IsWellDefinedForMorphisms := " never" ,
225
- IsWellDefinedForTwoCells := " never" ,
226
- RandomObjectByInteger := " never" ,
227
- RandomMorphismByInteger := " never" ,
228
- RandomMorphismWithFixedSourceByInteger := " never" ,
229
- RandomMorphismWithFixedRangeByInteger := " never" ,
230
- RandomMorphismWithFixedSourceAndRangeByInteger := " never" ,
231
- RandomObjectByList := " never" ,
232
- RandomMorphismByList := " never" ,
233
- RandomMorphismWithFixedSourceByList := " never" ,
234
- RandomMorphismWithFixedRangeByList := " never" ,
235
- RandomMorphismWithFixedSourceAndRangeByList := " never" ,
236
- # object and morphism data must never be cashed
237
- # because `IsEqualForCache*` might involve them,
238
- # possibly leading to an infinite recursion
239
- ObjectDatum := " never" ,
240
- MorphismDatum := " never" ,
241
- );
249
+ obj!. caches := rec ( );
250
+
251
+ for operation_name in CAP_INTERNAL.operation_names_with_cache_disabled_by_default do
252
+
253
+ obj!. caches.(operation_name) := " none" ;
254
+
255
+ od ;
242
256
243
257
obj!. redirects := rec ( );
244
258
@@ -385,8 +399,7 @@ InstallMethod( SetCaching,
385
399
386
400
fi ;
387
401
388
- if not IsBound ( category!. caches.( function_name ) ) or
389
- ( IsString( category!. caches.( function_name ) ) and category!. caches.( function_name ) <> " never" ) then
402
+ if not IsBound ( category!. caches.( function_name ) ) or IsString( category!. caches.( function_name ) ) then
390
403
391
404
category!. caches.( function_name ) := caching_info;
392
405
@@ -465,8 +478,8 @@ InstallGlobalFunction( SetCachingOfCategory,
465
478
466
479
for current_name in RecNames( category!. caches ) do
467
480
468
- if current_name in [ " IsEqualForMorphisms " , " IsEqualForObjects " , " IsEqualForMorphismsOnMor " , " IsEqualForCacheForMorphisms " , " IsEqualForCacheForObjects " ] then
469
- continue ; # # Those are needed for comparison in caches
481
+ if current_name in CAP_INTERNAL.operation_names_with_cache_disabled_by_default then
482
+ continue ;
470
483
fi ;
471
484
472
485
SetCaching( category, current_name, type );
0 commit comments