d1ct - a hybrid object/mapping
FEATURES
- directly inherited from dict
- accessible by attribute. o.x == o['x']
- This works also for all corner cases.
- json.dumps json.loads
- vars() works on it!
- hashable! (should not yet trust on it, though)
- autocomplete works even if the objects comes from a list
- best of all, it works recursively. So all inner dicts will become d1cts too.
CHANGELOG
version 1.0.5
- added the capability to not only accept dict-like mappings, but also lists of objects
which will be returned as a list of d1ct-objects.
So no worries if you send it the json.loads output (which can be either a list or dict)
NO DOWNSIDES?
oh hell yeah it got downsides
the performance which is a magnitude slower (~6x) than builtin dict
to give you an impression of timeit results:
d1ct
0.26289230000111274
0.2543108999961987
0.25743720002355985
0.2560539000260178
0.2556736999831628
0.25478869999642484
0.2541010999993887
0.2552008999919053
0.2651131000020541
0.25846979999914765
dict
0.04928750000544824
0.04902900001616217
0.049049399996874854
0.050644999981159344
0.0496991999971214
0.04940899999928661
0.0497540999785997
0.04959690000396222
0.04939249999006279
0.04959330000565387
So... this implementation might have side effects which I did not notice, because of different use cases or whatever.
Usage / Testing
import d1ct
d = d1ct({"a": 1, "b": {"b1": "c1"}}, kw1=1, kw2=2)
d["z1"] = {}
d.z1.update({"yyyy": 2323232})
assert d.a == d['a'] == 1
assert d.z1 == d['z1'] == {'yyyy': 2323232}
assert d == {'a': 1, 'b': {'b1': 'c1'}, 'kw1': 1, 'kw2': 2, 'z1': {'yyyy': 2323232}}
assert type(d.z1) is d1ct
d.z1.update({"yyyy": 2323232})
assert type(d.z1.yyyy) is int
d.z1.update({"yyyy": {"xbb": [1, 2, 23]}})
assert type(d.z1.yyyy) is d1ct
import json
json.dumps(d)
d |= {'more_keys': {'really': 'yeah!'}}
assert d == {'a': 1,'b': {'b1': 'c1'}, 'kw1': 1,'kw2': 2, 'z1': {'yyyy': {'xbb': [1, 2, 23] } },'more_keys': {'really': 'yeah!'} }
Metadata
Release files for d1ct 1.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| d1ct-1.0.5.tar.gz | 8.1 kB | Without provenance | Details for d1ct-1.0.5.tar.gz |
Release files / d1ct-1.0.5.tar.gz
| Download URL | d1ct-1.0.5.tar.gz |
|---|---|
| Size | 8.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
18d0513d0fb476828c256703bf185ae5fd4e5dfc30d863b88ba99a6d0daf99cb
|
|
BLAKE2b-256 checksum How to use checksums |
1573a169bb4c1112d83b852d9eb57b73a347379dd20ba464bdef8832b70ea0c0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.28.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1
|
Security for d1ct 1.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.