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