From 80ba8240f7133e34337f0b7dfd2db2d52b5840a5 Mon Sep 17 00:00:00 2001 From: Ryan Grout Date: Mon, 3 Jul 2017 12:26:02 -0500 Subject: [PATCH] A slightly faster interposed. Replace the call to islice with a call to next(). --- toolz/itertoolz.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/toolz/itertoolz.py b/toolz/itertoolz.py index 2462c5fb..a25eea3c 100644 --- a/toolz/itertoolz.py +++ b/toolz/itertoolz.py @@ -520,8 +520,9 @@ def interpose(el, seq): >>> list(interpose("a", [1, 2, 3])) [1, 'a', 2, 'a', 3] """ - combined = zip(itertools.repeat(el), seq) - return drop(1, concat(combined)) + inposed = concat(zip(itertools.repeat(el), seq)) + next(inposed) + return inposed def frequencies(seq):