@@ -159,58 +159,6 @@ def is_immutable_sequence(thing):
159159 isinstance (thing , collections .MutableSequence )
160160
161161
162- def parse_slice (s ):
163- '''
164- Parse a `slice` object into a canonical `(start, stop, step)`.
165-
166- This is helpful because `slice`'s own `.start`, `.stop` and `.step` are
167- sometimes specified as `None` for convenience, so Python will infer them
168- automatically. Here we make them explicit.
169-
170- if `start` is `None`, it will be set to `0` (if the `step` is positive) or
171- `infinity` (if the `step` is negative.)
172-
173- if `stop` is `None`, it will be set to `infinity` (if the `step` is
174- positive) or `0` (if the `step` is negative.)
175-
176- If `step` is `None`, it will be changed to the default `1`.
177- '''
178- assert isinstance (s , slice )
179-
180- ### Parsing `step`:
181- assert s .step != 0
182- if s .step is None :
183- step = 1
184- else :
185- step = s .step
186- ###
187-
188- ### Parsing `start`:
189- if s .start is not None :
190- start = s .start
191- else :
192- assert s .start is None
193- if step > 0 :
194- start = 0
195- else :
196- assert step < 0
197- start = infinity
198- ###
199-
200- ### Parsing `stop`:
201- if s .stop is not None :
202- stop = s .stop
203- else :
204- assert s .stop is None
205- if step > 0 :
206- stop = infinity
207- else :
208- assert step < 0
209- stop = - infinity
210- ###
211-
212- return (start , stop , step )
213-
214162
215163def to_tuple (single_or_sequence , item_type = None , item_test = None ):
216164 '''
@@ -360,7 +308,6 @@ def ensure_iterable_is_sequence(iterable, default_type=tuple,
360308 return default_type (iterable )
361309
362310
363-
364311class CanonicalSlice : # blockodo replace parse_slice everywhere
365312 def __init__ (self , slice_ , iterable_or_length = None , offset = 0 ):
366313 '''
@@ -481,7 +428,7 @@ def __init__(self, slice_, iterable_or_length=None, offset=0):
481428
482429
483430
484- class CuteSequenceMixin (shy_misc_tools .AlternativeLengthMixin ):
431+ class CuteSequenceMixin (misc_tools .AlternativeLengthMixin ):
485432 def take_random (self ):
486433 return self [random .randint (0 , get_length (self ))]
487434
0 commit comments