OO, complexity and toons...

Shagshag shagshag13 at yahoo.fr
Mon May 13 16:55:00 EDT 2002


Hello,

Imagine we have toons, cartoon and a huge cartoons encyclopedia...

class toon:
	__init__(self, name, kind):
		self.name = name
		self.kind = kind
	...

t1 = toon('Daffy', 'duck')
t2 = toon('Bugs', 'bunny')
t3 = toon('Babs', 'bunny')
t4 = toon('Mickey', 'mouse')
t5 = toon('Minnie', 'mouse')
t6 = toon('Bugs', 'bug') # another Bugs
...
ti = toon('Jerry', 'mouse')
...
tn = toon('Tom', 'cat')


class cartoon
	__init__(self, title, *featuring):	
		self.title = title
		self.featuring = featuring
	...

c1 = cartoon('title1', (t1, t2, t3))
c2 = cartoon('title2', (t4, t5))
c2 = cartoon('title2', (t2, t3))
...
cm = cartoon('titlem', (ti, tj, ... tn))

class cartoons
	# a huge cartoons encyclopedia = collection of m cartoon
	# (c1, c2, c3, ... cm)
	...

n should be > 10,000 and m > 500,000

I am looking for the best data structure to handle this in python (i'm
not sure that theses classes are well suited for a "good object
model"), and more important the best way to search through cartoons
[efficiently = O(p*log p) ???], all cartoon featuring theses
properties :

- with Bugs bunny and another bunny, 
- featuring toons whose name is Bugs, 
- featuring toons which are mouse
- featuring Mickey (mouse) and Donald (duck) and Dingo (*any*) and ...
and so on...

And i was wondering if i should handle this with "list" with python
index() method, having strict equality (name and kind), lenient (name
or king) and how should i do that...

thanks in advance for helping my toons...



More information about the Python-list mailing list