On 6 Sep., 09:30, Paul McGuire <[EMAIL PROTECTED]> wrote: > On Sep 6, 12:47 am, Dr Mephesto <[EMAIL PROTECTED]> wrote: > > > > > I need some real speed! a database is waaay to slow for the algorithm > > im using. and because the sublists are of varying size, i dont think I > > can use an array...- Hide quoted text - > > > - Show quoted text - > > How about a defaultdict approach? > > from collections import defaultdict > > dataArray = defaultdict(lambda : [[],[],[],[],[]]) > dataArray[1001][3].append('x') > dataArray[42000][2].append('y') > > for k in sorted(dataArray.keys()): > print "%6d : %s" % (k,dataArray[k]) > > prints: > 1001 : [[], [], [], ['x'], []] > 42000 : [[], [], ['y'], [], []] > > -- Paul
hey, that defaultdict thing looks pretty cool... whats the overhead like for using a dictionary in python? dave -- http://mail.python.org/mailman/listinfo/python-list