Skip to main content

DotWiz is a blazing fast dict subclass that enables accessing (nested) keys in dot notation.

Project description

https://img.shields.io/pypi/v/dotwiz.svg https://img.shields.io/pypi/pyversions/dotwiz.svg https://codecov.io/gh/rnag/dotwiz/branch/main/graph/badge.svg?token=J3YW230U8Z https://github.com/rnag/dotwiz/actions/workflows/dev.yml/badge.svg Documentation Status Updates

A blazing fast dict subclass that enables dot access notation via Python attribute style. Nested dict and list values are automatically transformed as well.

Install

$ pip install dotwiz

Usage

Here is an example of how to create and use a DotWiz object:

from dotwiz import DotWiz

dw = DotWiz({'this': {'works': {'for': [{'nested': {'values': True}}]}}},
            the_answer_to_life=42)

print(dw)
# >  DotWiz(this=DotWiz(works=DotWiz(for=[DotWiz(nested=DotWiz(values=True))])),
#           the_answer_to_life=42)

assert dw.this.works['for'][0].nested.values  # True
assert dw.the_answer_to_life == 42

Using make_dot_wiz allows you to pass in an iterable object when creating a DotWiz object:

from dotwiz import make_dot_wiz

dw = make_dot_wiz([('hello, world!', 123), ('easy: as~ pie?', True)],
                  AnyKey='value')

print(dw)
#> DotWiz(AnyKey='value', hello, world!=123, easy: as~ pie?=True)

assert dw['hello, world!'] == 123
assert dw['easy: as~ pie?']
assert dw.AnyKey == 'value'

Features

  • TODO

Benchmarks

Check out the Benchmarks section in the docs for more info.

Using a dot-access approach such as DotWiz can be up to 100x faster than with make_dataclass from the dataclasses module.

It’s also about 5x faster to create a DotWiz from a dict object as compared to other libraries such as prodict – or close to 15x faster than creating a Box – and up to 10x faster in general to access keys by dot notation – or almost 30x faster than accessing keys from a DotMap.

Contributing

Contributions are welcome! Open a pull request to fix a bug, or open an issue to discuss a new feature or change.

Check out the Contributing section in the docs for more info.

Credits

This package was created with Cookiecutter and the rnag/cookiecutter-pypackage project template.

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

dotwiz-0.2.0.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

dotwiz-0.2.0-py2.py3-none-any.whl (6.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file dotwiz-0.2.0.tar.gz.

File metadata

  • Download URL: dotwiz-0.2.0.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for dotwiz-0.2.0.tar.gz
Algorithm Hash digest
SHA256 7e40aabda6b150494d05893d1ca08ea90465385589461dd5bc6dbfff52088b3b
MD5 94a8751ae27e0e73277ae8e8f569a53a
BLAKE2b-256 c832bdd54bbc1242355799701241d8f797a49a7ede0bb674dd36490b56cd6bc8

See more details on using hashes here.

File details

Details for the file dotwiz-0.2.0-py2.py3-none-any.whl.

File metadata

  • Download URL: dotwiz-0.2.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for dotwiz-0.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c6688dec21fa242d7b2b1188e0e11e8d0c1f5d8799d5a33e431bbf1ad108ec75
MD5 36c899b8c4774ec708253c3e0d464e26
BLAKE2b-256 4f9ed91a6fee46f77676c260b8418601ad2443f4eb5d3d12d1a8cfdf67f7bc26

See more details on using hashes here.

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