This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author upendra-k14
Recipients upendra-k14
Date 2016-01-03.14:21:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1451830918.88.0.211778162331.issue26002@psf.upfronthosting.co.za>
In-reply-to
Content
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 )
History
Date User Action Args
2016-01-03 14:21:58upendra-k14setrecipients: + upendra-k14
2016-01-03 14:21:58upendra-k14setmessageid: <1451830918.88.0.211778162331.issue26002@psf.upfronthosting.co.za>
2016-01-03 14:21:58upendra-k14linkissue26002 messages
2016-01-03 14:21:58upendra-k14create