mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-05 17:00:58 +01:00
_hist_get_portion try islice first
This commit is contained in:
parent
d2536198ae
commit
a1d742e7d0
1 changed files with 8 additions and 0 deletions
|
@ -9,6 +9,7 @@ import uuid
|
|||
import argparse
|
||||
import builtins
|
||||
import functools
|
||||
import itertools
|
||||
import operator
|
||||
import threading
|
||||
import collections
|
||||
|
@ -414,6 +415,13 @@ def _hist_get_session(session='session', location=None):
|
|||
|
||||
def _hist_get_portion(commands, slices):
|
||||
"""Yield from portions of history commands. """
|
||||
if len(slices) == 1:
|
||||
s = ensure_slice(slices[0])
|
||||
try:
|
||||
yield from itertools.islice(commands, s.start, s.stop, s.step)
|
||||
return
|
||||
except ValueError: # islice failed
|
||||
pass
|
||||
commands = list(commands)
|
||||
for s in slices:
|
||||
s = ensure_slice(s)
|
||||
|
|
Loading…
Add table
Reference in a new issue