Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #10601

Deeply nested dictionaries - should I look into a database or am I just doing it wrong?

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!nerim.net!novso.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <bahamutzero8825@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'bug': 0.02; 'cpython': 0.05; 'distinct': 0.05; 'instance': 0.05; '(use': 0.09; 'namespace': 0.09; 'prefix': 0.09; 'top-level': 0.09; 'broken': 0.12; 'exception': 0.12; '3.2.1': 0.16; 'dictionaries': 0.16; 'received:192.168.1.6': 0.16; 'subject: \n ': 0.16; 'subject:database': 0.16; 'subject:wrong': 0.16; 'thunderbird': 0.16; 'received:209.85.210.174': 0.19; 'received:mail- iy0-f174.google.com': 0.19; 'figure': 0.21; 'filter': 0.22; 'module,': 0.23; 'refers': 0.23; 'wonder': 0.23; 'skip:( 30': 0.24; 'specify': 0.25; '(e.g.': 0.25; 'windows': 0.26; 'raise': 0.28; 'mode': 0.28; 'class.': 0.29; 'id:': 0.29; 'object': 0.30; 'skip:( 20': 0.30; 'module': 0.30; 'case).': 0.30; 'enabled': 0.30; 'subject:?': 0.31; "won't": 0.32; 'go.': 0.32; 'message- id:@gmail.com': 0.32; 'typically': 0.33; 'rather': 0.33; 'to:addr :python-list': 0.34; 'header:User-Agent:1': 0.34; 'calling': 0.34; 'backend': 0.35; 'dll': 0.35; 'pretty': 0.35; "isn't": 0.35; 'data,': 0.35; 'some': 0.37; 'but': 0.37; 'using': 0.37; 'received:192': 0.38; 'received:google.com': 0.38; 'received:209.85': 0.38; 'user': 0.38; 'configured': 0.38; 'received:192.168.1': 0.39; 'data': 0.39; 'to:addr:python.org': 0.39; 'received:209': 0.40; "i'd": 0.40; 'methods': 0.40; 'piece': 0.62; 'cause': 0.69; 'relevant': 0.69; 'categories': 0.73; '5.0': 0.84; 'subject:should': 0.84; 'plugins': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :x-enigmail-version:content-type:content-transfer-encoding; bh=XGhAZQvwoGEWyx0bYRuYNM+Lvpsd4CvFhbJah+Z4fmw=; b=cU3XiyRQVl2n1TxfOjayVfSkOXCT2YPCVMgcKTpGMVavTN6JDqGjdsrfkJZyKKJuC1 cH+bThpqjvP8a2CyiD8XamvNkKebzcOMKvHmFoT8Vuu3e95jImKZgJbtg9R7l4Ln6qlg adQZozC9mglzXZTWzgkS26nwptt3B9SYPTprA=
Date Sat, 30 Jul 2011 16:57:04 -0500
From Andrew Berg <bahamutzero8825@gmail.com>
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20110624 Thunderbird/5.0
MIME-Version 1.0
To "comp.lang.python" <python-list@python.org>
Subject Deeply nested dictionaries - should I look into a database or am I just doing it wrong?
X-Enigmail-Version 1.2
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1676.1312063033.1164.python-list@python.org> (permalink)
Lines 96
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1312063033 news.xs4all.nl 23899 [2001:888:2000:d::a6]:41275
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:10601

Show key headers only | View raw


As part of my muxer/encoder backend module, I need to store data in its
main class. While each instance won't typically store a lot of data, but
I really want it broken up into distinct categories so that a program
using the module won't need to figure out what piece of data refers to
what (e.g. is the current item using yadif via FFmpeg or AviSynth?) and
so that methods can be configured not to accept data that isn't relevant
(e.g. I don't want a bug in the calling program to cause the module to
use AviSynth methods if the user wants to use FFmpeg; I'd rather raise
an exception in this case). This is my (incomplete) layout of how I'd
nest the dictionaries:

> main
> 	demuxer
> 	video_encoder
> 	audio_encoder
> 	muxer
> io
> 	input_file
> 	prefix
> 	output_file
> video
> 	enabled
> 	mode (pal/ntsc/ivtc/film)
> 	fps
> 		fpsr
> 		fpsd
> 		fpsin
> 		fpsout
> audio
> 	enabled
> 	type (copy/aac/mp3/(l)pcm/etc.)
> avs
> 	enabled
> 	location
> 		dll
> 		plugins
> 	demuxer
> 		type (DirectShowSource/AVISource/etc.)
> 		dss_opts
> 		avis_opts
> 		
> 	filter
> 		deint/ivtc/none
> 			yadif
> 				enabled
> 				opts
> 			titvc
> 				enabled
> 				tdopts
> 				tfmopts
> 		fft3d
> 			enabled/gpu
> 			ffte
> 			ffts
> tsmuxer
> 	enabled
> 	location
> 	meta (T/F)
> x264
> 	enabled
> 	location
> 	usepreset (use presets or specify commands explicitly?)
> 	rcmethod
> 	crf
> 	bitrate
> 	cur_pass
> 	total_pass
> 	turbo (check x264 docs!)
> 	keyint
> 	min_keyint
> 	
> 	
> sox
> 	enabled
> 	location
> 	vol
> ffmpeg
> 	enabled
> 	location
> 	audio/video/both
> 	video
> 		x264
> 			
> 	audio
> 		acodec
> 	

Top-level items in the namespace of the object (e.g. QueueItem.x264).
Deeper are dictionaries within (e.g.
QueueItem.x264['avs']['filter']['fft3d']['ffte']).
Some of these can nest pretty deeply, so I wonder if dictionaries are
the right way to go.

-- 
CPython 3.2.1 | Windows NT 6.1.7601.17592 | Thunderbird 5.0
PGP/GPG Public Key ID: 0xF88E034060A78FCB

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Deeply nested dictionaries - should I look into a database or am I just doing it wrong? Andrew Berg <bahamutzero8825@gmail.com> - 2011-07-30 16:57 -0500

csiph-web