369 def __and__(self, other): |
369 def __and__(self, other): |
370 return self._fastsetop(other, '__and__') |
370 return self._fastsetop(other, '__and__') |
371 |
371 |
372 def __sub__(self, other): |
372 def __sub__(self, other): |
373 return self._fastsetop(other, '__sub__') |
373 return self._fastsetop(other, '__sub__') |
|
374 |
|
375 def _slice(self, start, stop): |
|
376 # creating new list should be generally cheaper than iterating items |
|
377 if self._ascending is None: |
|
378 return baseset(self._list[start:stop], istopo=self._istopo) |
|
379 |
|
380 data = self._asclist |
|
381 if not self._ascending: |
|
382 start, stop = max(len(data) - stop, 0), max(len(data) - start, 0) |
|
383 s = baseset(data[start:stop], istopo=self._istopo) |
|
384 s._ascending = self._ascending |
|
385 return s |
374 |
386 |
375 def __repr__(self): |
387 def __repr__(self): |
376 d = {None: '', False: '-', True: '+'}[self._ascending] |
388 d = {None: '', False: '-', True: '+'}[self._ascending] |
377 s = _formatsetrepr(self._datarepr) |
389 s = _formatsetrepr(self._datarepr) |
378 if not s: |
390 if not s: |