diff --git a/vm/src/stdlib/bisect.rs b/vm/src/stdlib/bisect.rs index 0a02c06b4..830d14ddc 100644 --- a/vm/src/stdlib/bisect.rs +++ b/vm/src/stdlib/bisect.rs @@ -114,16 +114,38 @@ mod _bisect { Ok(lo) } + /// Return the index where to insert item x in list a, assuming a is sorted. + /// + /// The return value i is such that all e in a[:i] have e < x, and all e in + /// a[i:] have e >= x. So if x already appears in the list, a.insert(x) will + /// insert just before the leftmost x already there. + /// + /// Optional args lo (default 0) and hi (default len(a)) bound the + /// slice of a to be searched. #[pyfunction] fn bisect_left(args: BisectArgs, vm: &VirtualMachine) -> PyResult { bisect_left_impl(args, vm) } + /// Return the index where to insert item x in list a, assuming a is sorted. + /// + /// The return value i is such that all e in a[:i] have e <= x, and all e in + /// a[i:] have e > x. So if x already appears in the list, a.insert(x) will + /// insert just after the rightmost x already there. + /// + /// Optional args lo (default 0) and hi (default len(a)) bound the + /// slice of a to be searched. #[pyfunction] fn bisect_right(args: BisectArgs, vm: &VirtualMachine) -> PyResult { bisect_right_impl(args, vm) } + /// Insert item x in list a, and keep it sorted assuming a is sorted. + /// + /// If x is already in a, insert it to the left of the leftmost x. + /// + /// Optional args lo (default 0) and hi (default len(a)) bound the + /// slice of a to be searched. #[pyfunction] fn insort_left(BisectArgs { a, x, lo, hi }: BisectArgs, vm: &VirtualMachine) -> PyResult { let index = bisect_left_impl( @@ -138,6 +160,12 @@ mod _bisect { vm.call_method(&a, "insert", (index, x)) } + /// Insert item x in list a, and keep it sorted assuming a is sorted. + /// + /// If x is already in a, insert it to the right of the rightmost x. + /// + /// Optional args lo (default 0) and hi (default len(a)) bound the + /// slice of a to be searched #[pyfunction] fn insort_right(BisectArgs { a, x, lo, hi }: BisectArgs, vm: &VirtualMachine) -> PyResult { let index = bisect_right_impl(