Live data from Hacker News

Box: Python dictionaries with recursive dot notation access

github.com

1–10 of 124 posts

Re: Box: Python dictionaries with recursive dot notation access

#4

How is this different from addict? https://github.com/mewwts/addict

I wonder if addict convert keys like "Funky Foobar Key!" into Funky_Foobar_Key? The README seems to use keys that cleanly convert to python dict keys, so it's not clear.

Re: Box: Python dictionaries with recursive dot notation access

#5
post #2

How is the performance on this for very large dictionaries vs. standard python dictionary lookups?

A really good question. I haven't looked much at the code but I'd imagine still O(1) because it's just converting the keys into a different format.

Re: Box: Python dictionaries with recursive dot notation access

#6
What happens if the dictionary has the keys 'John Doe' and 'John_Doe'?

Can you use 'self' as a key?

Ive used a class to provide this kind of dot notation fererencing of hierarchical data. If you could enclose the keys in quotes I might feel better about it but that's probably not possible.

Re: Box: Python dictionaries with recursive dot notation access

#7
A single class that:

* De/serializes JSON and YAML

* De/mangles, de/encodes keys

* Provides automatic, expensive hashcode

* Blacklists/transforms a bunch of likely keys because they conflict with reserved words

* Overlays attrs (__box_heritage)

* All in pretty complex code that obfuscates what you're really doing (especially to a maintainer)

For the ability to avoid importing json/PyYAML and use clear key lookups? The author must really like JavaScript syntax, or something, because I'm not seeing the point in this layer at all. It's the sort of library that you discover your inherited codebase is using, and just say, "fuckfuckfuck...", because it implies that the author cares more about pushing round pegs into square holes than writing the freaking application code; it reeks of inexperience.

Re: Box: Python dictionaries with recursive dot notation access

#8

A single class that: * De/serializes JSON and YAML * De/mangles, de/encodes keys * Provides automatic, expensive hashcode * Blacklists/transforms a bunch of likely keys because they conflict with reserved words * Overlays attrs (__box_heritage) * All in pretty complex code that obfuscates what you're really doing (especially to a maintainer) For the ability to avoid importing json/PyYAML and use clear key lookups? Th…

> For the ability to avoid importing json/PyYAML and use clear key lookups?

I think the advantage over json/PyYAML is not having to supply conversion functions for Decimal, datetime, or user defined datatypes.

Re: Box: Python dictionaries with recursive dot notation access

#9

A single class that: * De/serializes JSON and YAML * De/mangles, de/encodes keys * Provides automatic, expensive hashcode * Blacklists/transforms a bunch of likely keys because they conflict with reserved words * Overlays attrs (__box_heritage) * All in pretty complex code that obfuscates what you're really doing (especially to a maintainer) For the ability to avoid importing json/PyYAML and use clear key lookups? Th…

> For the ability to avoid importing json/PyYAML and use clear key lookups? I think the advantage over json/PyYAML is not having to supply conversion functions for Decimal, datetime, or user defined datatypes.

I agree that that's useful, but it should be a separate library, and I'd be surprised if there weren't a few already (I'm guilty of writing one-off serializers for datetimes/dates).
Post reply on HN