flatdict icon indicating copy to clipboard operation
flatdict copied to clipboard

Clarification on ambiguous as_dict()

Open devleaks opened this issue 2 years ago • 0 comments

Hello,

I apologize if I misunderstand the documentation but what is the purpose of the as_dict() help function?

import flatdict

>>> c = flatdict.FlatDict({"a": {"b":1}})
>>> print(type(c), c)
<class 'flatdict.FlatDict'> {'a:b': 1}

>>> d = flatdict.FlatDict({"a": {"b":1}}).as_dict()
>>> print(type(d), d)
<class 'dict'> {'a': {'b': 1}}

>>> e = dict(flatdict.FlatDict({"a": {"b":1}}))
>>> print(type(e), e)
<class 'dict'> {'a:b': 1}

I understood that as_dict() returns the result (the flattened dict) as a standard python dictionary rather than a flatdict.FlatDict object. It is not the case. Can you please clarify, and lift the ambiguity in the doc. Thank you.

Otherwise, this is a very handy package. Thank you.

P.

PS: Calling with .as_dict() takes a lot of time on larger dictionaries.

devleaks avatar Jun 03 '22 15:06 devleaks