Skip to main content

Dict that lazily populates itself with items from the iterator it was constructed with as keys are accessed

Project description

IterDicts are almost exactly like regular Python dicts, except that they’re only populated upon demand. This gives them most of the same advantages of generators, such as the ability to operator on very large (or infinite!) datasets. For example:

Accessing keys that aren’t populated yet

>>> d = IterDict((a, a) for a in xrange(1000000000000000))  # 1 quadrillion (US)
>>> d[10]
10

Deleting keys that aren’t populated yet

>>> del d[20]
>>> del d[20]
KeyError: 20

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

IterDict-0.1.0.tar.gz (5.3 kB view hashes)

Uploaded Source

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