{"library":"sortedcontainers-stubs","title":"Sorted Containers Stubs","type":"library","description":"Community-maintained Python type stubs for the `sortedcontainers` library, which provides `dict`, `set`, and `list` data structures that automatically maintain the order of their elements by value. These stubs enable type checkers (like Mypy or Pyright) to enforce API details, including specific requirements for keys/values and special constructor return types, making `sortedcontainers` easier to use in type-checked codebases. The major and minor versions of `sortedcontainers-stubs` are designed to align with the corresponding major and minor versions of `sortedcontainers` itself. Current version is 2.4.3.","language":"python","status":"active","last_verified":"Mon May 18","install":{"commands":["pip install sortedcontainers-stubs"],"cli":null},"imports":["from sortedcontainers import SortedList","from sortedcontainers import SortedDict","from sortedcontainers import SortedSet","from sortedcontainers import SortedDict","from sortedcontainers import SortedSet"],"auth":{"required":false,"env_vars":[]},"links":{"homepage":null,"github":"https://github.com/h4l/sortedcontainers-stubs","docs":null,"changelog":"https://github.com/h4l/sortedcontainers-stubs/blob/main/CHANGELOG.md","pypi":"https://pypi.org/project/sortedcontainers-stubs/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null},"quickstart":{"code":"from typing import List, Tuple\nfrom sortedcontainers import SortedList, SortedDict, SortedSet\n\n# Example with SortedList\ndef process_sorted_list(data: List[int]) -> SortedList[int]:\n    sl = SortedList(data)\n    sl.add(0)\n    return sl\n\nmy_list: SortedList[int] = process_sorted_list([3, 1, 4, 1, 5])\nprint(f\"SortedList: {my_list}\")\n\n# Example with SortedDict\ndef process_sorted_dict(data: List[Tuple[str, int]]) -> SortedDict[str, int]:\n    sd = SortedDict(data)\n    sd['apple'] = 100\n    return sd\n\nmy_dict: SortedDict[str, int] = process_sorted_dict([('banana', 2), ('orange', 1)])\nprint(f\"SortedDict: {my_dict}\")\n\n# Example with SortedSet\ndef process_sorted_set(data: List[int]) -> SortedSet[int]:\n    ss = SortedSet(data)\n    ss.add(10)\n    return ss\n\nmy_set: SortedSet[int] = process_sorted_set([3, 1, 4, 1, 5])\nprint(f\"SortedSet: {my_set}\")\n\n# To verify type checking, run a type checker like Mypy: `mypy your_script.py`\n# The sortedcontainers-stubs package provides the type information for these objects.","lang":"python","description":"Install `sortedcontainers-stubs` and then use `sortedcontainers` as usual with type hints. Type checkers will automatically discover the stubs. This example demonstrates basic usage of `SortedList`, `SortedDict`, and `SortedSet` with explicit type annotations.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-18","installed_version":"2.4.3","pypi_latest":"2.4.3","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":1.7,"avg_import_s":0.01,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"sortedcontainers-stubs","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.01,"mem_mb":0.4,"disk_size":"18.4M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"sortedcontainers-stubs","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":1.6,"import_time_s":0.01,"mem_mb":0.4,"disk_size":"19M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"sortedcontainers-stubs","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.02,"mem_mb":0.6,"disk_size":"20.3M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"sortedcontainers-stubs","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":1.7,"import_time_s":0.01,"mem_mb":0.6,"disk_size":"21M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"sortedcontainers-stubs","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.01,"mem_mb":0.6,"disk_size":"12.2M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"sortedcontainers-stubs","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":1.6,"import_time_s":0.01,"mem_mb":0.6,"disk_size":"13M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"sortedcontainers-stubs","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.02,"mem_mb":0.9,"disk_size":"11.9M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"sortedcontainers-stubs","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":1.5,"import_time_s":0.01,"mem_mb":0.7,"disk_size":"12M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"sortedcontainers-stubs","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.01,"mem_mb":0.4,"disk_size":"17.9M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"sortedcontainers-stubs","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":1.9,"import_time_s":0.01,"mem_mb":0.4,"disk_size":"18M"}]}}