Skip to content

Commit b9ba943

Browse files
committed
use islice to implement take
1 parent 7efba5a commit b9ba943

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

pyenumerable/implementations/pure_python.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
from __future__ import annotations
22

33
from collections.abc import Callable, Iterable, Sequence
4-
from contextlib import suppress
5-
from itertools import chain
4+
from itertools import chain, islice
65
from typing import Any, Protocol
76

87
from pyenumerable.protocol import Associable, Enumerable
@@ -251,9 +250,9 @@ def take(
251250
) -> Enumerable[TSource]:
252251
return PurePythonEnumerable(
253252
*(
254-
self.source[start_or_count:end]
253+
islice(self.source, start_or_count, end)
255254
if (end is not None)
256-
else self.source[:start_or_count]
255+
else islice(self.source, start_or_count)
257256
),
258257
)
259258

0 commit comments

Comments
 (0)