sorted unique elements from a list; using 2.3 features
just at xs4all.nl
Mon Jan 6 22:11:59 CET 2003
In article <YhlS9.24314$NB4.6001 at FE05>,
"Steve Holden" <sholden at holdenweb.com> wrote:
> Presumably (I don't have 2.3 to hand, so I may get shot down in flames)
> since a set has __iter__() one could also use
> subset = [x for x in sets.Set(data)]
> to create the list you want to sort? I'm not convinced this is a win,
> though, so timings might be interesting.
list(iterable) is the canonical way to get a list from an iterable.
Using a list comp doesn't look like a win to me at all... It definitely
won't be a win speed-wise, as list() iterates in C and any list comp
involves Python code.
More information about the Python-list