Show More
@@ -2117,9 +2117,13 b' class lazyset(object):' | |||
|
2117 | 2117 | def __init__(self, subset, condition): |
|
2118 | 2118 | self._subset = subset |
|
2119 | 2119 | self._condition = condition |
|
2120 | self._cache = {} | |
|
2120 | 2121 | |
|
2121 | 2122 | def __contains__(self, x): |
|
2122 | return x in self._subset and self._condition(x) | |
|
2123 | c = self._cache | |
|
2124 | if x not in c: | |
|
2125 | c[x] = x in self._subset and self._condition(x) | |
|
2126 | return c[x] | |
|
2123 | 2127 | |
|
2124 | 2128 | def __iter__(self): |
|
2125 | 2129 | cond = self._condition |
General Comments 0
You need to be logged in to leave comments.
Login now