Compute max with caching. Caching is by the identity of `seq` rather than the value. It is thus important that `seq` is a tuple of immutable objects, and this function is intended for use where `seq` is a value that will persist (generally block sizes). Parameters ---------
(seq)
| 2099 | |
| 2100 | |
| 2101 | def cached_max(seq): |
| 2102 | """Compute max with caching. |
| 2103 | |
| 2104 | Caching is by the identity of `seq` rather than the value. It is thus |
| 2105 | important that `seq` is a tuple of immutable objects, and this function |
| 2106 | is intended for use where `seq` is a value that will persist (generally |
| 2107 | block sizes). |
| 2108 | |
| 2109 | Parameters |
| 2110 | ---------- |
| 2111 | seq : tuple |
| 2112 | Values to reduce |
| 2113 | |
| 2114 | Returns |
| 2115 | ------- |
| 2116 | tuple |
| 2117 | """ |
| 2118 | assert isinstance(seq, tuple) |
| 2119 | # Look up by identity first, to avoid a linear-time __hash__ |
| 2120 | # if we've seen this tuple object before. |
| 2121 | result = _max(_HashIdWrapper(seq)) |
| 2122 | return result |
| 2123 | |
| 2124 | |
| 2125 | def cached_cumsum(seq, initial_zero=False): |
no test coverage detected
searching dependent graphs…