Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #29477
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2012-09-19 03:24 -0700 |
| Message-ID | <345da32c-a22b-4025-bb50-794d684885b1@googlegroups.com> (permalink) |
| Subject | Using dict as object |
| From | Pierre Tardy <tardyp@gmail.com> |
One thing that is cooler with java-script than in python is that dictionaries and objects are the same thing. It allows browsing of complex hierarchical data syntactically easy. For manipulating complex jsonable data, one will always prefer writing: buildrequest.properties.myprop rather than brdict['properties']['myprop'] This ability in JS is well known for its flaws (e.g. http://drupal.org/node/172169#forin ), and I understand why this is not a feature that we want in python by default. I did work on class that adds this feature, and that I wish to use for manipulating my json data. The following github pull request to buildbot has tests that defines specification of such a class, and has several commits, which gives several implementation of the same thing. https://github.com/buildbot/buildbot/pull/525 All implementation I tried are much slower than a pure native dict access. Each implementation have bench results in commit comment. All of them are 20+x slower than plain dict! I would like to have python guys advices on how one could optimize this. I'd like to eventually post this to python-dev, please tell if this is really not a good idea. Regards, Pierre
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Using dict as object Pierre Tardy <tardyp@gmail.com> - 2012-09-19 03:24 -0700 Re: Using dict as object Dave Angel <d@davea.name> - 2012-09-19 07:45 -0400 Re: Using dict as object Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2012-09-19 15:02 +0200 Re: Using dict as object Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2012-09-19 14:04 +0000 Re: Using dict as object Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2012-09-19 23:04 +0000
csiph-web