[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

I've writing a Python GUI for some measurement devices and

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 6
Thread images: 1

I've writing a Python GUI for some measurement devices and my code will be used and adopted by some others too, while I keep watching over it.

Now there I have a dict of dicts
d = {
'KEY1' : {'key1': val1, 'key2' : val2},
'KEY2' : {'key3': val3, 'key4' : val4},
...
}
etc., or even deeper dicts.
and they'll have to access the values.
Now I'm thinking, for clarity, wirting access functios where they only need to provide the small keys

get(self, 'key'):
for KEY, VALUES in d.iteritems():
if 'key' in VALUES:
return d[KEY]['key']

however, of course then they'd scan the whole long dicts a lot.

Without trying it, is this probably a rather fast thing and thus negligible, or is that a complete horrible thing to do?

All dicts have about size 10 or so
>>
>>55952289
Throw it in Mongo/CouchDB?
>>
>>55952307
I should elaborate on that a bit, it would probably speed up query times a lot and and separate code and data a little better. I'd benchmark it to see if it's really an issue though.
>>
>>55952339
The code also executes pyvia and pyqt4 commands, so I think those are rather the bottleneck functions. I just want to know if the programming Karma god will hunt my down if I run unnecessay for loops for the sake of providing clearer API sort of commands

Adding more software other than Python modules isn't a good idea, I think.
>>
With that small dicts, the time it takes is very negligible.

If for some reason you want to optimize it anyway, you could put all the keys in a set and do an "if key in set" check on that set instead. That way you only have to do one lookup.
>>
>>55953077
Whoops, I misread your question.

Scrap the set suggestion. Instead, since you only do lookup on the nested dicts, you might as well just put them all into one.
Thread posts: 6
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.