fast way to filter a set?
Nicola Mingotti
nicola-mingotti at libero.it
Wed Sep 17 12:51:59 EDT 2003
More information about the Python-list mailing list
Wed Sep 17 12:51:59 EDT 2003
- Previous message (by thread): fast way to filter a set?
- Next message (by thread): fast way to filter a set?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
fortepianissimo at yahoo.com.tw (Fortepianissimo) writes: > I know I can do things like > > s=Set(range(1,11)) > s=Set(filter(lambda x:x%2==0,s)) > > But this seems a bit slow since filter returns a list which then must > be converted back to a set. Any tips? Thanks! Can you ? I tried python2.3 and 2.2 and it replies : "NameError: name 'Set' is not defined" . There is a PEP but it seems it's steel 'under consideration'. http://www.python.org/peps/pep-0218.html May be , if this proposal is accepted you one day could write : { x for x in S if x%2 == 0 } # S be a set . bye.
- Previous message (by thread): fast way to filter a set?
- Next message (by thread): fast way to filter a set?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list