Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def tee(iterable, n=2):
if n >= 0 and _coconut.isinstance(iterable, (_coconut.tuple, _coconut.frozenset)):
return (iterable,) * n
if n > 0 and (_coconut.hasattr(iterable, "__copy__") or _coconut.isinstance(iterable, _coconut.abc.Sequence)):
return (iterable,) + _coconut.tuple(_coconut.copy.copy(iterable) for _ in _coconut.range(n - 1))
return _coconut.itertools.tee(iterable, n)
class reiterable(object):
def args(self):
return _coconut.tuple(self._argdict.get(i) for i in _coconut.range(self._arglen)) + self._stargs
def __call__(self, *args, **kwargs):
def __reduce__(self):
return (self.__class__, _coconut.tuple(self.patterns))
def __get__(self, obj, objtype=None):
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):
def makedata(data_type, *args):
"""Construct an object of the given data_type containing the given arguments."""
if _coconut.hasattr(data_type, "_make") and _coconut.issubclass(data_type, _coconut.tuple):
return data_type._make(args)
if _coconut.issubclass(data_type, (_coconut.map, _coconut.range, _coconut.abc.Iterator)):
return args
if _coconut.issubclass(data_type, _coconut.str):
return "".join(args)
return data_type(args)
def fmap(func, obj):
def __reduce__(self):
return (self.__class__, (self.func,) + _coconut.tuple(self.funcstars))
def __get__(self, obj, objtype=None):
def __iter__(self):
iterator = _coconut.iter(self.iter)
loop = True
while loop:
group = []
for _ in _coconut.range(self.group_size):
try:
group.append(_coconut.next(iterator))
except _coconut.StopIteration:
loop = False
break
if group:
yield _coconut.tuple(group)
def __len__(self):