Skip to main content

A sorted dictionary with nearest-key lookup

Project description

https://travis-ci.com/ncsuarc/FuzzySortedDict.svg?branch=master

fuzzysorteddict is a sorted dictionary with nearest-key lookups.

>>> from fuzzysorteddict import FuzzySortedDict
>>> d = FuzzySortedDict()
>>> d[1] = 1
>>> d[2] = 2
>>> d[1.75]
2

FuzzySortedDict can be particularly useful for sparsely populated ranges, such as when working with time.

>>> from fuzzysorteddict import FuzzySortedDict
>>> import datetime
>>> d = FuzzySortedDict()
>>> d[datetime.datetime(2000, 1, 1, 12, 0, 0)] = 1
>>> d[datetime.datetime(2000, 1, 1, 12, 0, 4)] = 2
>>> d[datetime.datetime(2000, 1, 1, 12, 0, 1)]
1

Installation

FuzzySortedDict is easily installed with pip.

pip install fuzzysorteddict

Project details


Download files

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

Files for fuzzysorteddict, version 1.1.0
Filename, size File type Python version Upload date Hashes
Filename, size fuzzysorteddict-1.1.0-py3-none-any.whl (3.5 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size fuzzysorteddict-1.1.0.tar.gz (3.3 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page