bisect module
bisect_left, bisect_right, insort_left, insort_right, and the aliases bisect and insort are available.
- Sequences must be built-in containers. Searches accept lists, tuples, strings, bytes, ranges and deques;
integer-indexed
Counterobjects also support searches. Insertion accepts lists and deques. User-defined sequences cannot supply__len__and__getitem__, following the general class limitations. - Index width is fixed at 64 bits. Bounds and implicit range lengths use signed 64-bit indices even on 32-bit WebAssembly; CPython uses its platform index width.
- Key functions cannot suspend to the host. As with
sorted(key=...), a key function that calls an external or OS function raisesNotImplementedErrorat the suspension point. Ordinary sandbox functions and built-in callables work. - User-defined ordering follows Monty’s comparison support. Custom comparison dunders have the same restrictions as ordinary comparisons; see classes.md.
- Function metadata follows other built-in Monty module functions. Their representation uses
<function ...>rather than CPython’s<built-in function ...>, and CPython’s function metadata is not exposed. The module does not expose CPython’s__all__list or its private_bisectaccelerator module.