Message257419
statistics.median_grouped currently uses cf=data.index(x) to find the leftmost position of x in data ( line number 445 ). Here, data.index() has linear time complexity, which may not be good for long lists.
But, here since the list 'data' is sorted beforehand, we can use binary search ( bisect_left() ) to find the leftmost occurrence of 'x' in 'data'.
Similarly, for counting number of occurrence of 'x' in data after sorting, we can find the position of rightmost occurrence of 'x' in data[l1....len(data)], where l1 is position of leftmost occurrence of 'x' (line number 447 ) |
|
Date |
User |
Action |
Args |
2016-01-03 14:21:58 | upendra-k14 | set | recipients:
+ upendra-k14 |
2016-01-03 14:21:58 | upendra-k14 | set | messageid: <1451830918.88.0.211778162331.issue26002@psf.upfronthosting.co.za> |
2016-01-03 14:21:58 | upendra-k14 | link | issue26002 messages |
2016-01-03 14:21:58 | upendra-k14 | create | |
|