Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Wrapper for the dict class that extends the functionality for nested dicts including navigating using keypaths and nested key searching. This includes mixed dicts and lists.
Version: 1.2.2
A wrapper for python dicts that allows you to search and navigate through nested dicts using key paths. Also works with mixed dictionaries (mixuture of nested lists and dicts). Derived from a need to search for keys in a nested dictionary; too much time was spent on building yet another full class for nested dictionaries, but it suited our needs.
Quick Start Example:
>>> from nesteddictionary import NestedDict #import the NestedDict class
>>> d = {'path':{'to':{'key':'val'}}} #normal way of doing nested dictionary
>>> nested_dict = NestedDict( d ) #created a nested dictionary from a normal dictionary
Features:
nested_dict[ ['path','to','key'] ]
which is the same as nested_dict['path']['to']['key']
)nested_dict.get('path.to.key')
)nested_dict.insert( ['newpath','to','key'], 'newval'
) will add to the existing dictionay, resulting in: NestedDict({ 'path':{'to':{'key':'val'}}, 'newpath':{'to':{'key':'newval'}} })
).Limitations:
Changes (PEP 440: major.minor.patch):
For comparison, when doing (these are not included in tests, but are easy enough to write and test on your own):
>>> d = [{1:{2:'value'}}]
>>> %timeit using_reduce(d,[0,1,2]) #reduce from functools
>>> %timeit using_recursion(d,[0,1,2]) #what was used in v1, more pythonic
>>> %timeit d[0][1][2] #direct access; fastest
Yields:
>>> 648 ns ± 3.17 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each) #reduce
>>> 1.77 µs ± 4.05 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each) #recursion
>>> 89.3 ns ± 0.448 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each) #direct
References:
FAQs
Wrapper for the dict class that extends the functionality for nested dicts including navigating using keypaths and nested key searching. This includes mixed dicts and lists.
We found that nesteddictionary demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.