D
deathweaselx86
Howdy guys, I am new.
I've been converting lists to sets, then back to lists again to get
unique lists.
e.g
Python 2.5.2 (r252:60911, Jan 20 2010, 21:48:48)
[GCC 4.2.4 (Ubuntu 4.2.4-1ubuntu3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
I used to use list comps to do this instead.
A very long time ago, we all used dictionaries, but I'm not interested
in that ever again. ;-)
Is there any performance hit to using one of these methods over the
other for rather large lists?
I've been converting lists to sets, then back to lists again to get
unique lists.
e.g
Python 2.5.2 (r252:60911, Jan 20 2010, 21:48:48)
[GCC 4.2.4 (Ubuntu 4.2.4-1ubuntu3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
['1', '3', '2', '5']foo = ['1','2','3']
bar = ['2','5']
foo.extend(bar)
foo = list(set(foo))
foo
I used to use list comps to do this instead.
['1', '2', '3', '5']foo = ['1','2','3']
bar = ['2','5']
foo.extend([a for a in bar if a not in foo])
foo
A very long time ago, we all used dictionaries, but I'm not interested
in that ever again. ;-)
Is there any performance hit to using one of these methods over the
other for rather large lists?