3 def memoizer_immutable_args(name
):
4 def make_memoized(func
):
6 func
._cache
_it
_cache
= func_cache_it_cache
= {}
9 return func_cache_it_cache
[args
]
12 except TypeError, msg
:
13 if 'dict objects are unhashable'==str(msg
):
16 func_cache_it_cache
[args
] = r
= func(*args
)
18 all_caches
[name
] = func_cache_it_cache
22 def memoizer_Symbol_new(func
):
23 func
._cache
_it
_cache
= func_cache_it_cache
= {}
24 def wrapper(cls
, name
, dummy
=False, **options
):
26 return func(cls
, name
, dummy
=dummy
, **options
)
28 return func_cache_it_cache
[name
]
31 func_cache_it_cache
[name
] = r
= func(cls
, name
, dummy
=dummy
, **options
)
33 all_caches
['Symbol.__new__'] = func_cache_it_cache
36 def memoizer_Interval_new(func
):
37 func
._cache
_it
_cache
= func_cache_it_cache
= {}
38 def wrapper(cls
, a
, b
=None, **options
):
40 # to ensure that Interval(a) is Interval(a,a)
45 return func_cache_it_cache
[args
]
48 func_cache_it_cache
[args
] = r
= func(cls
, a
, b
, **options
)
50 all_caches
['Interval.__new__'] = func_cache_it_cache
53 def memoizer_Float_new(func
):
54 func
._cache
_it
_cache
= func_cache_it_cache
= {}
55 def wrapper(cls
, x
=0, prec
=None, mode
=None, **options
):
56 if prec
is None: prec
= cls
._prec
57 if mode
is None: mode
= cls
._mode
58 args
= (x
, prec
, mode
)
60 return func_cache_it_cache
[args
]
63 func_cache_it_cache
[args
] = r
= func(cls
, *args
, **options
)
65 all_caches
['Float.__new__'] = func_cache_it_cache
69 """Clear all cached objects."""
70 for cache
in all_caches
.values():