{"id":7477,"library":"ordereddict","title":"OrderedDict (Python 2.x Backport)","description":"The 'ordereddict' library provides a backport of the `collections.OrderedDict` class, originally introduced in Python 2.7 and 3.1, for use in older Python 2.x environments (specifically Python 2.4, 2.5, and 2.6). It enables maintaining the insertion order of keys in a dictionary-like structure. This package is no longer maintained and serves only historical compatibility purposes for very old Python 2 projects.","status":"abandoned","version":"1.1","language":"python","source_language":"en","source_url":"https://github.com/twitter-archive/commons/blob/master/src/python/twitter/common/collections/ordereddict.py","tags":["ordered dictionary","python 2","backport","collections","legacy"],"install":[{"cmd":"pip install ordereddict","lang":"bash","label":"Install for Python 2.x"}],"dependencies":[],"imports":[{"wrong":"import ordereddict","symbol":"OrderedDict","correct":"from ordereddict import OrderedDict"}],"quickstart":{"code":"import sys\n\n# This library is for Python 2.x <= 2.6\n# For Python 2.7+ or 3.x, use 'from collections import OrderedDict'\n\nif sys.version_info < (2, 7) and sys.version_info >= (2, 4):\n    from ordereddict import OrderedDict\n    print(\"Using ordereddict backport\")\n    od = OrderedDict()\n    od['first'] = 1\n    od['second'] = 2\n    od['third'] = 3\n    print(od.items())\nelse:\n    print(\"This library is not needed for your Python version.\")\n    print(\"Use 'from collections import OrderedDict' instead.\")\n","lang":"python","description":"Demonstrates importing and using the `OrderedDict` class from the backport for Python 2.4-2.6. It includes a version check to highlight the library's specific compatibility window."},"warnings":[{"fix":"For Python 2.7+, use `from collections import OrderedDict`. For Python 3.7+, a regular `dict` maintains insertion order, so `OrderedDict` might only be needed for specific API compatibility or advanced features like `move_to_end` or order-sensitive equality comparisons.","message":"This 'ordereddict' library is obsolete for modern Python versions. `collections.OrderedDict` is built into Python 2.7, Python 3.1, and later. Furthermore, standard Python dictionaries (`dict`) guarantee insertion order since Python 3.7.","severity":"breaking","affected_versions":"Python 2.7+, Python 3.x"},{"fix":"Avoid using this backport unless strictly required for compatibility with Python 2.4-2.6. Prioritize `collections.OrderedDict` or standard `dict` where possible.","message":"The performance characteristics of this Python-based backport `ordereddict.OrderedDict` may differ significantly from the C-optimized `collections.OrderedDict` in newer Python versions.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'2':3,28,67,72 '2.4':33 '2.5':34 '2.6':36 '2.7':20 '3.1':22 'backport':5,11,73 'class':15 'collect':74 'collections.ordereddict':14 'compat':61 'dictionari':48,70 'dictionary-lik':47 'enabl':38 'environ':30 'histor':60 'insert':41 'introduc':17 'key':44 'legaci':75 'librari':8 'like':49 'longer':55 'maintain':39,56 'old':65 'older':26 'order':42,69 'ordereddict':1,7 'origin':16 'packag':52 'project':68 'provid':9 'purpos':62 'python':2,19,27,32,66,71 'serv':58 'specif':31 'structur':50 'use':24 'x':4,29","created_at":"2026-04-16T13:59:59.281986+00:00","updated_at":"2026-04-16T13:59:59.281986+00:00","problems":{"verify_error":"Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\n  File \"/tmp/tmpqmot8p6r/venv/lib/python3.12/site-packages/ordereddict.py\", line 23, in <module>\n    from UserDict import DictMixin\nModuleNotFoundError: No module named 'UserDict'"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.1","cli_name":"","cli_version":null,"type":"library","homepage":"UNKNOWN","github":null,"docs":null,"changelog":null,"pypi":"https://pypi.org/project/ordereddict/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"import_fail","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-07-10","install_tag":null}}