This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!
Project Description


indexed.IndexedOrderedDict is fully compatible with collections.OrderedDict and can be used as a drop in replacement. The main difference is that key, value and item views support accessing elements by their index.

d = indexed.IndexedOrderedDict()
d["first-key"] = "first-value"
d["second-key"] = "second-value"
d["third-key"] = "third-value"

values = d.values()
assert values[2] == "third-value"

assert d.keys().index("second-key") == 1


  • Can be used with both Python 2 and 3. Provides keysview(), valuesview() and itemsview() which were removed from Python 3 for compability.
  • Access keys, values and items by index, e.g. d.keys()[5].
  • Find the index of a key, e.g. d.keys().index("key").

Excluding those additions the API is the same as the API of collections.OrderedDict(). Including:

  • Initializing, setting, getting and deleting items
  • Iterating forwards and in reverse
  • d.clear()
  • d.popitem(last=True)
  • d.move_to_end(key, last=True)
  • d.keys(), d.values(), d.items()
  • d.pop(key[, default])
  • d.setdefault(key, default=None)
  • String representation
  • Pickling
  • Copying
  • Creating from keys
  • Comparing order sensitively with other ordered dictionaries or order insensitively with standard mappings


The only dependencies are Python >= 2.7 or Python >= 3.0.

  • With pip:

    sudo pip install
  • With easy_install:

    sudo easy_install
  • From current source code:

    python build
    sudo python install


Performance is practically on the same order of magnitude as the built in collections.OrderedDict.

d collections.OrderedDict indexed.IndexedOrderedDict
Operation Avergage Worst case Average Worst case
d.copy() O(n) O(n) O(n) O(n)
d[key] O(1) O(n) O(1) O(n)
d[key] = value O(1) O(n) [1] O(1) O(n) [1]
del d[key] O(1) O(n) O(n) O(n)
d.keys()[i] O(n) [2] O(n) [2] O(1) O(1)
d.values()[i] O(n) [3] O(n) [3] O(1) O(n)
d.items()[i] O(n) [3] O(n) [3] O(1) O(n)
d.keys().index(x) O(n) [3] O(n) [3] O(n) O(n)
[1](1, 2) These are amortized worst case runtimes.
[2](1, 2) This does not work in Python 3 because colections.KeysView is not indexable. One of the theoretically best work arounds is next(itertools.islice(d.keys(), i, i + 1)).
[3](1, 2, 3, 4, 5, 6) Assuming the theoretically best possible workaround.

License is licensed under the GPL3. See the LICENSE file for full copyright and license information.

Release History

Release History


This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date (16.9 kB) Copy SHA256 Checksum SHA256 Source Sep 6, 2013

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting