Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def index(self, elem):
"""Find the index of elem in the count."""
if elem not in self:
raise _coconut.ValueError(_coconut.repr(elem) + " not in " + _coconut.repr(self))
return (elem - self.start) // self.step if self.step else 0
def __reversed__(self):
def index(self, elem):
"""Find the index of elem in the range."""
if elem not in self._xrange: raise _coconut.ValueError(_coconut.repr(elem) + " is not in range")
start, _, step = self._xrange.__reduce_ex__(2)[1]
return (elem - start) // step
def __repr__(self):
def index(self, elem):
"""Find the index of elem in the count."""
if elem not in self:
raise _coconut.ValueError(_coconut.repr(elem) + " not in " + _coconut.repr(self))
return (elem - self.start) // self.step if self.step else 0
def __reversed__(self):
def __iter__(self):
return _coconut.iter(self._get_new_iter())
def __getitem__(self, index):
def __new__(cls, function, iterable):
new_map = _coconut.itertools.starmap.__new__(cls, function, iterable)
new_map.func = function
new_map.iter = iterable
return new_map
def __getitem__(self, index):
def __call__(self, *args, **kwargs):
key = (args, _coconut.frozenset(kwargs))
use_backup = False
try:
hash(key)
except _coconut.Exception:
try:
key = _coconut.pickle.dumps(key, -1)
except _coconut.Exception:
use_backup = True
if use_backup:
for i, (k, v) in _coconut.enumerate(self.backup_tee_store):
if k == key:
to_tee, store_pos = v, i
break
else: # no break
to_tee = self.func(*args, **kwargs)
store_pos = None
to_store, to_return = _coconut_tee(to_tee)
if store_pos is None:
self.backup_tee_store.append([key, to_store])
else:
def __get__(self, obj, objtype=None):
return _coconut.functools.partial(self, obj)
def _coconut_forward_compose(func, *funcs): return _coconut_base_compose(func, *((f, 0) for f in funcs))
def __reversed__(self):
return self.__class__(self.func, _coconut_reversed(self.iter))
def __repr__(self):
return "filter(%r, %r)" % (self.func, self.iter)
def __reduce__(self):
return (self.__class__, (self.func, self.iter))
def __reduce_ex__(self, _):
return self.__reduce__()
def __copy__(self):
return self.__class__(self.func, _coconut.copy.copy(self.iter))
def __fmap__(self, func):
return _coconut_map(func, self)
class zip(_coconut.zip):
__slots__ = ("iters",)
if hasattr(_coconut.zip, "__doc__"):
__doc__ = _coconut.zip.__doc__
def __new__(cls, *iterables):
new_zip = _coconut.zip.__new__(cls, *iterables)
new_zip.iters = iterables
return new_zip
def __getitem__(self, index):
if _coconut.isinstance(index, _coconut.slice):
return self.__class__(*(_coconut_igetitem(i, index) for i in self.iters))
return _coconut.tuple(_coconut_igetitem(i, index) for i in self.iters)
def __reversed__(self):
return self.__class__(*(_coconut_reversed(i) for i in self.iters))
def __len__(self):
return _coconut.min(_coconut.len(i) for i in self.iters)
def __repr__(self):
return "zip(%s)" % (", ".join((_coconut.repr(i) for i in self.iters)),)
def __reduce__(self):
return (self.__class__, self.iters)
return self.__class__(*(_coconut_reversed(i) for i in self.iters))
def __len__(self):
return _coconut.min(_coconut.len(i) for i in self.iters)
def __repr__(self):
return "zip(%s)" % (", ".join((_coconut.repr(i) for i in self.iters)),)
def __reduce__(self):
return (self.__class__, self.iters)
def __reduce_ex__(self, _):
return self.__reduce__()
def __copy__(self):
return self.__class__(*_coconut.map(_coconut.copy.copy, self.iters))
def __fmap__(self, func):
return _coconut_map(func, self)
class enumerate(_coconut.enumerate):
__slots__ = ("iter", "start")
if hasattr(_coconut.enumerate, "__doc__"):
__doc__ = _coconut.enumerate.__doc__
def __new__(cls, iterable, start=0):
new_enumerate = _coconut.enumerate.__new__(cls, iterable, start)
new_enumerate.iter = iterable
new_enumerate.start = start
return new_enumerate
def __getitem__(self, index):
if _coconut.isinstance(index, _coconut.slice):
return self.__class__(_coconut_igetitem(self.iter, index), self.start + (0 if index.start is None else index.start if index.start >= 0 else len(self.iter) + index.start))
return (self.start + index, _coconut_igetitem(self.iter, index))
def __len__(self):
return _coconut.len(self.iter)
def __repr__(self):
return "enumerate(%r, %r)" % (self.iter, self.start)
def __reduce__(self):
return (self.__class__, (self.iter, self.start))
def add(self, func):
self.__doc__ = _coconut.getattr(func, "__doc__", None) or self.__doc__
if _coconut.isinstance(func, _coconut_base_pattern_func):
self.patterns += func.patterns
else:
self.patterns.append(func)
def __call__(self, *args, **kwargs):