a bit OT: If you want to bisect a slice, then bisect a slice: > > result = bisect_right(a[lo:hi], x) > > Oh, wait, what if a has billions of elements and creating a slice > containing a million or two out of the middle is too expensive?
Yup, that's why Iproposed about a year ago on this list that there should be a way to get a slice view (or slice iterator, AKA islice) easily :-) You can use itertools.islice for this though -- oops, no you can't: TypeError Traceback (most recent call last) <ipython-input-36-9efe49979a8e> in <module> ----> 1 result = bisect.bisect_right(islice(a, lo, hi), x) TypeError: object of type 'itertools.islice' has no len() We really do need a slice view :-) -CHB -- Christopher Barker, PhD (Chris) Python Language Consulting - Teaching - Scientific Software Development - Desktop GUI and Web Development - wxPython, numpy, scipy, Cython
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/F2CITCVKT3E3RHCH7UUFDUURIBQLJI65/ Code of Conduct: http://python.org/psf/codeofconduct/