Message164334
max and min for a range object are already O(1) one-liners:
>>> a = range(3, 21, 5)
>>> a[-1] if a.step > 0 else a[0] # max(a)
18
>>> a[0] if a.step > 0 else a[-1] # min(a)
3
As for __and__, it doesn't feel like a particularly natural operation to me, given that a range object represents an *ordered* sequence of integers rather than just a subset. For example, what should the first element of
range(7, -3, -2) & range(10)
be? 7 or 1? And why? |
|
Date |
User |
Action |
Args |
2012-06-29 17:02:26 | mark.dickinson | set | recipients:
+ mark.dickinson, Yclept.Nemo |
2012-06-29 17:02:26 | mark.dickinson | set | messageid: <1340989346.45.0.0351452219527.issue15224@psf.upfronthosting.co.za> |
2012-06-29 17:02:25 | mark.dickinson | link | issue15224 messages |
2012-06-29 17:02:25 | mark.dickinson | create | |
|