Skip to main content

Cython implementation of Python's collections.OrderedDict

Project description

https://travis-ci.org/shoyer/cyordereddict.svg?branch=master

A drop-in replacement for the standard library’s OrderedDict that is 2-3x faster. Currently only for Python 2.7.

Benchmarks:

Test

Code

Ratio (stdlib / cython)

__init__ empty

OrderedDict()

1.7

__init__ list

OrderedDict(list_data)

3.2

__init__ dict

OrderedDict(dict_data)

3.1

__setitem__

ordereddict[-1] = False

2.9

__getitem__

ordereddict[100]

2.4

update

ordereddict.update(dict_data)

2.9

__iter__

list(ordereddict)

5.7

__contains__

100 in ordereddict

1.8

Numbers larger than 1 mean cyorderedict is faster. To run yourself, use cyordereddict.benchmark().

Install:

pip install cyordereddict

Dependencies:

cyorderedict is written with Cython, but requires no dependecies other than CPython and a C compiler.

Use:
try:
    from cyordereddict import OrderedDict
except ImportError:
    from collections import OrderedDict
License:

MIT. cyordereddict is largely adapted from the Python standard library, which is available under the Python Software Foundation License.

Project details


Download files

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

Source Distribution

cyordereddict-0.1.tar.gz (47.9 kB view details)

Uploaded Source

File details

Details for the file cyordereddict-0.1.tar.gz.

File metadata

  • Download URL: cyordereddict-0.1.tar.gz
  • Upload date:
  • Size: 47.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for cyordereddict-0.1.tar.gz
Algorithm Hash digest
SHA256 aabd64a098022a4347cf905036f606e1d4181e570ae632a642a4d65c3e5219bc
MD5 aff258b100f1dec5f8fea1aaffeee545
BLAKE2b-256 4def79953e5331bb12276ae09d56b53ee3f6eb8d67429395cbf4be29ade47653

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page